package com.dqyt.khjc.controller;

import com.alibaba.fastjson.JSON;
import com.dqyt.app.bean.*;
import com.dqyt.app.mongo.LocaGzlqrdDao;
import com.dqyt.app.mongo.MaintenanceDao;
import com.dqyt.app.mongo.ReportDao;
import com.dqyt.app.mongo.SampleDao;
import com.dqyt.khjc.bean.*;
import com.dqyt.khjc.mapper.ReceiptTbMapper;
import com.dqyt.khjc.mapper.UserMapper;
import com.dqyt.khjc.mapper.WorkMapper;
import com.dqyt.khjc.utils.TimeUtil;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Decoder;
import sun.misc.Resource;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;

@RestController
public class DownLoadGzltjdController {

    @Autowired
    private WorkMapper workMapper;
    @Autowired
    private ReportDao reportDao;
    @Autowired
    private MaintenanceDao maintenanceDao;
    @Autowired
    private SampleDao sampleDao;
    @Autowired
    private ReceiptTbMapper receiptTbMapper;


    @Autowired
    private UserMapper userMapper;


    @Autowired
    private LocaGzlqrdDao locaGzlqrdDao;


    public static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
        try {
            response.setCharacterEncoding("UTF-8");
            response.setHeader("content-Type", "application/vnd.ms-excel");
            response.setHeader("Content-Disposition",
                    "attachment;filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\"");
            workbook.write(response.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    /**
     * 工作量统计单  下载
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/api/dlGzltjdQz")
    public void dlGzltjdQz(HttpServletResponse response, HttpServletRequest request, String rwdbh, String sTime, String eTime,
                           String wtfId, String jyyId, String wtf, String wtfchId, String wtfch) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            ClassPathResource cpr = new ClassPathResource("excleTemplate/rwtjd.xlsx");
            InputStream is = cpr.getInputStream();
            Workbook workbook = new XSSFWorkbook(is);
            Sheet sheet0 = workbook.getSheetAt(0);


            long mwtfId = 0L;
            long mjyyId = 0L;
            long mwtfchId = 0L;

            if (wtfId.equals("-99")) {
                mwtfId = -1;
            } else {
                mwtfId = Long.parseLong(wtfId);
            }

            if (jyyId.equals("-99")) {
                mjyyId = 0;
            } else {
                mjyyId = Long.parseLong(jyyId);
            }

            if (wtfchId.equals("-99")) {
                mwtfchId = -1;
            } else {
                mwtfchId = Long.parseLong(wtfchId);
            }


            if (rwdbh.equals("-99")) {
                rwdbh = "-1";
            }

            String startTimeStr = "";
            String endTimeStr = "";

            if ("-99".equals(sTime)) {
                startTimeStr = "";
            } else {
                startTimeStr = sTime;
            }

            if ("-99".equals(eTime)) {
                endTimeStr = "";
            } else {
                endTimeStr = eTime;
            }
            //-------------------------------------------------------数据处理----------------------------------------------------
            long startTime = 0;
            long endTime = 0;
            if (!"".equals(startTimeStr)) {
                startTime = TimeUtil.formatDate_5(startTimeStr);
            }

            //
            if (!"".equals(endTimeStr)) {
                endTime = TimeUtil.formatDate_5(endTimeStr);
            }
            //根据条件号查询 work表
            List<WorkBean> mw = workMapper.getWorkStatistics(rwdbh, mwtfId, mwtfchId, startTime, endTime, mjyyId);

            //把所有的标识编号都取出来
            List<String> bsbhList = new ArrayList<>();
            for (WorkBean workBean : mw) {
                bsbhList.add(workBean.getBsbh());
            }


            //然后查询已完成的报告 面罩的个数统计
            List<Report> mzNumbers = reportDao.getReportByBatch(bsbhList, 1);
            int numberMzJm = 0;
            for (Report report : mzNumbers) {
                //除去维修替换了 背板/减压器
                boolean isbh = report.bsbh.contains("_old");
                if (!isbh) {
                    numberMzJm++;
                }
            }

            //根据 任务单编号和类型查询 已完成的报告 气瓶的个数统计
            List<Report> qpNumbers = reportDao.getReportByBatch(bsbhList, 2);
            int numberQpJm = 0;
            for (Report report2 : qpNumbers) {
                //除去维修替换了 背板/减压器
                boolean isbh = report2.bsbh.contains("_old");
                if (!isbh) {
                    numberQpJm++;
                }
            }

            //统计充气的气瓶有多少个
            //List<Report> msamples=  reportDao.getReportByrwdbhOrCqBath(bsbhList);
            List<Sample> msamples = sampleDao.getReportByrwdbhOrCqBath(bsbhList);

            int numberQpCqJm = 0;
            //维修
            for (Sample mSample : msamples) {
                //除去维修替换了 背板/减压器
                boolean isbh = mSample.bsbh.contains("_old");
                if (!isbh) {
                    numberQpCqJm++;
                }
            }
            //查询维修个数
            List<Maintenance> maintenances = maintenanceDao.getMaintenanceByRwdbhBath(bsbhList);
            HashSet<String> bjmcSet = new HashSet<String>();
            for (Maintenance maiobj : maintenances) {

                if (!"".equals(maiobj.mzGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.mzGhbjpp);
                    }
                }
                if (!"".equals(maiobj.gqfGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.gqfGhbjpp);
                    }
                }
                if (!"".equals(maiobj.bjqGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.bjqGhbjpp);
                    }
                }
                if (!"".equals(maiobj.ylbGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.ylbGhbjpp);
                    }
                }
                if (!"".equals(maiobj.jyqGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.jyqGhbjpp);
                    }
                }
                if (!"".equals(maiobj.bbGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.bbGhbjpp);
                    }
                }
                if (!"".equals(maiobj.pfGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.pfGhbjpp);
                    }
                }
                if (!"".equals(maiobj.qpGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.qpGhbjpp);
                    }
                }
                if (!"".equals(maiobj.xzGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.xzGhbjpp);
                    }
                }
            }
            //名牌名称
            String t_mc1 = "";
            String t_mc2 = "";
            String t_mc3 = "";
            String t_mc4 = "";
            String t_mc5 = "";
            String t_mc6 = "";
            String t_mc7 = "";
            String t_mc8 = "";

            //第一行
            int t_mz1 = 0;
            int t_mz2 = 0;
            int t_mz3 = 0;
            int t_mz4 = 0;
            int t_mz5 = 0;
            int t_mz6 = 0;
            int t_mz7 = 0;
            int t_mz8 = 0;
            String t_str_mc1 = "";
            String t_str_mc2 = "";
            String t_str_mc3 = "";
            String t_str_mc4 = "";
            String t_str_mc5 = "";
            String t_str_mc6 = "";
            String t_str_mc7 = "";
            String t_str_mc8 = "";

            //第二行
            int t_gqf1 = 0;
            int t_gqf2 = 0;
            int t_gqf3 = 0;
            int t_gqf4 = 0;
            int t_gqf5 = 0;
            int t_gqf6 = 0;
            int t_gqf7 = 0;
            int t_gqf8 = 0;
            String t_str_gqf1 = "";
            String t_str_gqf2 = "";
            String t_str_gqf3 = "";
            String t_str_gqf4 = "";
            String t_str_gqf5 = "";
            String t_str_gqf6 = "";
            String t_str_gqf7 = "";
            String t_str_gqf8 = "";

            //第三行
            int t_bjq1 = 0;
            int t_bjq2 = 0;
            int t_bjq3 = 0;
            int t_bjq4 = 0;
            int t_bjq5 = 0;
            int t_bjq6 = 0;
            int t_bjq7 = 0;
            int t_bjq8 = 0;
            String t_str_bjq1 = "";
            String t_str_bjq2 = "";
            String t_str_bjq3 = "";
            String t_str_bjq4 = "";
            String t_str_bjq5 = "";
            String t_str_bjq6 = "";
            String t_str_bjq7 = "";
            String t_str_bjq8 = "";

            //第四行
            int t_ylb1 = 0;
            int t_ylb2 = 0;
            int t_ylb3 = 0;
            int t_ylb4 = 0;
            int t_ylb5 = 0;
            int t_ylb6 = 0;
            int t_ylb7 = 0;
            int t_ylb8 = 0;
            String t_str_ylb1 = "";
            String t_str_ylb2 = "";
            String t_str_ylb3 = "";
            String t_str_ylb4 = "";
            String t_str_ylb5 = "";
            String t_str_ylb6 = "";
            String t_str_ylb7 = "";
            String t_str_ylb8 = "";


            //第五行
            //减压器的
            int t_jyq1 = 0;
            int t_jyq2 = 0;
            int t_jyq3 = 0;
            int t_jyq4 = 0;
            int t_jyq5 = 0;
            int t_jyq6 = 0;
            int t_jyq7 = 0;
            int t_jyq8 = 0;
            //背板的
            int t_bb1 = 0;
            int t_bb2 = 0;
            int t_bb3 = 0;
            int t_bb4 = 0;
            int t_bb5 = 0;
            int t_bb6 = 0;
            int t_bb7 = 0;
            int t_bb8 = 0;
            String t_str_jyqOrBb1 = "";
            String t_str_jyqOrBb2 = "";
            String t_str_jyqOrBb3 = "";
            String t_str_jyqOrBb4 = "";
            String t_str_jyqOrBb5 = "";
            String t_str_jyqOrBb6 = "";
            String t_str_jyqOrBb7 = "";
            String t_str_jyqOrBb8 = "";


            //第六行
            int t_pf1 = 0;
            int t_pf2 = 0;
            int t_pf3 = 0;
            int t_pf4 = 0;
            int t_pf5 = 0;
            int t_pf6 = 0;
            int t_pf7 = 0;
            int t_pf8 = 0;
            String t_str_pf1 = "";
            String t_str_pf2 = "";
            String t_str_pf3 = "";
            String t_str_pf4 = "";
            String t_str_pf5 = "";
            String t_str_pf6 = "";
            String t_str_pf7 = "";
            String t_str_pf8 = "";

            //第7行
            String t_str_qp1 = "";
            String t_str_qp2 = "";
            String t_str_qp3 = "";
            String t_str_qp4 = "";
            String t_str_qp5 = "";
            String t_str_qp6 = "";
            String t_str_qp7 = "";
            String t_str_qp8 = "";
            int t_qp1 = 0;
            int t_qp2 = 0;
            int t_qp3 = 0;
            int t_qp4 = 0;
            int t_qp5 = 0;
            int t_qp6 = 0;
            int t_qp7 = 0;
            int t_qp8 = 0;

            //第八行
            int t_xz1 = 0;
            int t_xz2 = 0;
            int t_xz3 = 0;
            int t_xz4 = 0;
            int t_xz5 = 0;
            int t_xz6 = 0;
            int t_xz7 = 0;
            int t_xz8 = 0;
            String t_str_xz1 = "";
            String t_str_xz2 = "";
            String t_str_xz3 = "";
            String t_str_xz4 = "";
            String t_str_xz5 = "";
            String t_str_xz6 = "";
            String t_str_xz7 = "";
            String t_str_xz8 = "";

            //总数
            String t_totle1 = "";
            String t_totle2 = "";
            String t_totle3 = "";
            String t_totle4 = "";
            String t_totle5 = "";
            String t_totle6 = "";
            String t_totle7 = "";
            String t_totle8 = "";

            //把set转list
            List<String> setList = new ArrayList<String>(bjmcSet);
            //把品牌都设置到部件名称框里面
            for (int k = 0; k < setList.size(); k++) {
                switch (k) {
                    case 0:
                        t_mc1 = setList.get(k);
                        break;
                    case 1:
                        t_mc2 = setList.get(k);
                        break;
                    case 2:
                        t_mc3 = setList.get(k);
                        break;
                    case 3:
                        t_mc4 = setList.get(k);
                        break;
                    case 4:
                        t_mc5 = setList.get(k);
                        break;
                    case 5:
                        t_mc6 = setList.get(k);
                        break;
                    case 6:
                        t_mc7 = setList.get(k);
                        break;
                    case 7:
                        t_mc8 = setList.get(k);
                        break;
                }
            }

            for (int c = 0; c < maintenances.size(); c++) {
                Maintenance mobj = maintenances.get(c);
                //第一行--------------------------------------------------------------------------------------
                if (mobj.mzGhbjpp.equals(t_mc1) && !"".equals(t_mc1)) {
                    t_mz1 = t_mz1 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc2) && !"".equals(t_mc2)) {
                    t_mz2 = t_mz2 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc3) && !"".equals(t_mc3)) {
                    t_mz3 = t_mz3 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc4) && !"".equals(t_mc4)) {
                    t_mz4 = t_mz4 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc5) && !"".equals(t_mc5)) {
                    t_mz5 = t_mz5 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc6) && !"".equals(t_mc6)) {
                    t_mz6 = t_mz6 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc7) && !"".equals(t_mc7)) {
                    t_mz7 = t_mz7 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc8) && !"".equals(t_mc8)) {
                    t_mz8 = t_mz8 + 1;
                }


                //第二行--------------------------------------------------------------------------------------
                if (mobj.gqfGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_gqf1 = t_gqf1 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_gqf2 = t_gqf2 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_gqf3 = t_gqf3 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_gqf4 = t_gqf4 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_gqf5 = t_gqf5 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_gqf6 = t_gqf6 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_gqf7 = t_gqf7 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_gqf8 = t_gqf8 + 1;
                }

                //第三行--------------------------------------------------------------------------------------
                if (mobj.bjqGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_bjq1 = t_bjq1 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_bjq2 = t_bjq2 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_bjq3 = t_bjq3 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_bjq4 = t_bjq4 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_bjq5 = t_bjq5 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_bjq6 = t_bjq6 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_bjq7 = t_bjq7 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_bjq8 = t_bjq8 + 1;
                }


                //第四行--------------------------------------------------------------------------------------
                if (mobj.ylbGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_ylb1 = t_ylb1 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_ylb2 = t_ylb2 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_ylb3 = t_ylb3 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_ylb4 = t_ylb4 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_ylb5 = t_ylb5 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_ylb6 = t_ylb6 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_ylb7 = t_ylb7 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_ylb8 = t_ylb8 + 1;
                }


                //第五行--------------------------------------------------------------------------------------
                //减压器
                if (mobj.jyqGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_jyq1 = t_jyq1 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_jyq2 = t_jyq2 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_jyq3 = t_jyq3 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_jyq4 = t_jyq4 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_jyq5 = t_jyq5 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_jyq6 = t_jyq6 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_jyq7 = t_jyq7 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_jyq8 = t_jyq8 + 1;
                }
                //背板
                if (mobj.bbGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_bb1 = t_bb1 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_bb2 = t_bb2 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_bb3 = t_bb3 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_bb4 = t_bb4 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_bb5 = t_bb5 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_bb6 = t_bb6 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_bb7 = t_bb7 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_bb8 = t_bb8 + 1;
                }


                //第六行--------------------------------------------------------------------------------------
                if (mobj.pfGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_pf1 = t_pf1 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_pf2 = t_pf2 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_pf3 = t_pf3 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_pf4 = t_pf4 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_pf5 = t_pf5 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_pf6 = t_pf6 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_pf7 = t_pf7 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_pf8 = t_pf8 + 1;
                }

                //第七行--------------------------------------------------------------------------------------
                if (mobj.qpGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_qp1 = t_qp1 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_qp2 = t_qp2 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_qp3 = t_qp3 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_qp4 = t_qp4 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_qp5 = t_qp5 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_qp6 = t_qp6 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_qp7 = t_qp7 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_qp8 = t_qp8 + 1;
                }


                //第八行--------------------------------------------------------------------------------------
                if (mobj.xzGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_xz1 = t_xz1 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_xz2 = t_xz2 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_xz3 = t_xz3 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_xz4 = t_xz4 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_xz5 = t_xz5 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_xz6 = t_xz6 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_xz7 = t_xz7 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_xz8 = t_xz8 + 1;
                }
            }


            //第一行的值---------------------------------------------------------------------------------------------
            if (t_mz1 != 0) {
                t_str_mc1 = t_mz1 + "";
            }
            if (t_mz2 != 0) {
                t_str_mc2 = t_mz2 + "";
            }
            if (t_mz3 != 0) {
                t_str_mc3 = t_mz3 + "";
            }
            if (t_mz4 != 0) {
                t_str_mc4 = t_mz4 + "";
            }
            if (t_mz5 != 0) {
                t_str_mc5 = t_mz5 + "";
            }
            if (t_mz6 != 0) {
                t_str_mc6 = t_mz6 + "";
            }
            if (t_mz7 != 0) {
                t_str_mc7 = t_mz7 + "";
            }
            if (t_mz8 != 0) {
                t_str_mc8 = t_mz8 + "";
            }


            //第二行的值---------------------------------------------------------------------------------------------
            if (t_gqf1 != 0) {
                t_str_gqf1 = t_gqf1 + "";
            }
            if (t_gqf2 != 0) {
                t_str_gqf2 = t_gqf2 + "";
            }
            if (t_gqf3 != 0) {
                t_str_gqf3 = t_gqf3 + "";
            }
            if (t_gqf4 != 0) {
                t_str_gqf4 = t_gqf4 + "";
            }
            if (t_gqf5 != 0) {
                t_str_gqf5 = t_gqf5 + "";
            }
            if (t_gqf6 != 0) {
                t_str_gqf6 = t_gqf6 + "";
            }
            if (t_gqf7 != 0) {
                t_str_gqf7 = t_gqf7 + "";
            }
            if (t_gqf8 != 0) {
                t_str_gqf8 = t_gqf8 + "";
            }

            //第三行的值---------------------------------------------------------------------------------------------
            if (t_bjq1 != 0) {
                t_str_bjq1 = t_bjq1 + "";
            }
            if (t_bjq2 != 0) {
                t_str_bjq2 = t_bjq2 + "";
            }
            if (t_bjq3 != 0) {
                t_str_bjq3 = t_bjq3 + "";
            }
            if (t_bjq4 != 0) {
                t_str_bjq4 = t_bjq4 + "";
            }
            if (t_bjq5 != 0) {
                t_str_bjq5 = t_bjq5 + "";
            }
            if (t_bjq6 != 0) {
                t_str_bjq6 = t_bjq6 + "";
            }
            if (t_bjq7 != 0) {
                t_str_bjq7 = t_bjq7 + "";
            }
            if (t_bjq8 != 0) {
                t_str_bjq8 = t_bjq8 + "";
            }


            //第四行的值---------------------------------------------------------------------------------------------
            if (t_ylb1 != 0) {
                t_str_ylb1 = t_ylb1 + "";
            }
            if (t_ylb2 != 0) {
                t_str_ylb2 = t_ylb2 + "";
            }
            if (t_ylb3 != 0) {
                t_str_ylb3 = t_ylb3 + "";
            }
            if (t_ylb4 != 0) {
                t_str_ylb4 = t_ylb4 + "";
            }
            if (t_ylb5 != 0) {
                t_str_ylb5 = t_ylb5 + "";
            }
            if (t_ylb6 != 0) {
                t_str_ylb6 = t_ylb6 + "";
            }
            if (t_ylb7 != 0) {
                t_str_ylb7 = t_ylb7 + "";
            }
            if (t_ylb8 != 0) {
                t_str_ylb8 = t_ylb8 + "";
            }

            //第五行的值---------------------------------------------------------------------------------------------
            //将减压器和背板的数量加起来 才是背具总成
//            int jyqOrBb1 = t_jyq1 + t_bb1;
//            int jyqOrBb2 = t_jyq2 + t_bb2;
//            int jyqOrBb3 = t_jyq3 + t_bb3;
//            int jyqOrBb4 = t_jyq4 + t_bb4;
//            int jyqOrBb5 = t_jyq5 + t_bb5;
//            int jyqOrBb6 = t_jyq6 + t_bb6;
//            int jyqOrBb7 = t_jyq7 + t_bb7;
//            int jyqOrBb8 = t_jyq8 + t_bb8;

            int jyqOrBb1 = t_jyq1;
            int jyqOrBb2 = t_jyq2;
            int jyqOrBb3 = t_jyq3;
            int jyqOrBb4 = t_jyq4;
            int jyqOrBb5 = t_jyq5;
            int jyqOrBb6 = t_jyq6;
            int jyqOrBb7 = t_jyq7;
            int jyqOrBb8 = t_jyq8;



            //背板
            if (jyqOrBb1 != 0) {
                t_str_jyqOrBb1 = jyqOrBb1 + "";
            }
            if (jyqOrBb2 != 0) {
                t_str_jyqOrBb2 = jyqOrBb2 + "";
            }
            if (jyqOrBb3 != 0) {
                t_str_jyqOrBb3 = jyqOrBb3 + "";
            }
            if (jyqOrBb4 != 0) {
                t_str_jyqOrBb4 = jyqOrBb4 + "";
            }
            if (jyqOrBb5 != 0) {
                t_str_jyqOrBb5 = jyqOrBb5 + "";
            }
            if (jyqOrBb6 != 0) {
                t_str_jyqOrBb6 = jyqOrBb6 + "";
            }
            if (jyqOrBb7 != 0) {
                t_str_jyqOrBb7 = jyqOrBb7 + "";
            }
            if (jyqOrBb8 != 0) {
                t_str_jyqOrBb8 = jyqOrBb8 + "";
            }

            //第六行的值---------------------------------------------------------------------------------------------
            if (t_pf1 != 0) {
                t_str_pf1 = t_pf1 + "";
            }
            if (t_pf2 != 0) {
                t_str_pf2 = t_pf2 + "";
            }
            if (t_pf3 != 0) {
                t_str_pf3 = t_pf3 + "";
            }
            if (t_pf4 != 0) {
                t_str_pf4 = t_pf4 + "";
            }
            if (t_pf5 != 0) {
                t_str_pf5 = t_pf5 + "";
            }
            if (t_pf6 != 0) {
                t_str_pf6 = t_pf6 + "";
            }
            if (t_pf7 != 0) {
                t_str_pf7 = t_pf7 + "";
            }
            if (t_pf8 != 0) {
                t_str_pf8 = t_pf8 + "";
            }


            //第七行的值---------------------------------------------------------------------------------------------
            if (t_qp1 != 0) {
                t_str_qp1 = t_qp1 + "";
            }
            if (t_qp2 != 0) {
                t_str_qp2 = t_qp2 + "";
            }
            if (t_qp3 != 0) {
                t_str_qp3 = t_qp3 + "";
            }
            if (t_qp4 != 0) {
                t_str_qp4 = t_qp4 + "";
            }
            if (t_qp5 != 0) {
                t_str_qp5 = t_qp5 + "";
            }
            if (t_qp6 != 0) {
                t_str_qp6 = t_qp6 + "";
            }
            if (t_qp7 != 0) {
                t_str_qp7 = t_qp7 + "";
            }
            if (t_qp8 != 0) {
                t_str_qp8 = t_qp8 + "";
            }

            //第八行的值---------------------------------------------------------------------------------------------
            if (t_xz1 != 0) {
                t_str_xz1 = t_xz1 + "";
            }
            if (t_xz2 != 0) {
                t_str_xz2 = t_xz2 + "";
            }
            if (t_xz3 != 0) {
                t_str_xz3 = t_xz3 + "";
            }
            if (t_xz4 != 0) {
                t_str_xz4 = t_xz4 + "";
            }
            if (t_xz5 != 0) {
                t_str_xz5 = t_xz5 + "";
            }
            if (t_xz6 != 0) {
                t_str_xz6 = t_xz6 + "";
            }
            if (t_xz7 != 0) {
                t_str_xz7 = t_xz7 + "";
            }
            if (t_xz8 != 0) {
                t_str_xz8 = t_xz8 + "";
            }

            int totleNum1 = t_mz1 + t_mz2 + t_mz3 + t_mz4 + t_mz5 + t_mz6 + t_mz7 + t_mz8;
            int totleNum2 = t_gqf1 + t_gqf2 + t_gqf3 + t_gqf4 + t_gqf5 + t_gqf6 + t_gqf7 + t_gqf8;
            int totleNum3 = t_bjq1 + t_bjq2 + t_bjq3 + t_bjq4 + t_bjq5 + t_bjq6 + t_bjq7 + t_bjq8;
            int totleNum4 = t_ylb1 + t_ylb2 + t_ylb3 + t_ylb4 + t_ylb5 + t_ylb6 + t_ylb7 + t_ylb8;
            int totleNum5 = jyqOrBb1 + jyqOrBb2 + jyqOrBb3 + jyqOrBb4 + jyqOrBb5 + jyqOrBb6 + jyqOrBb7 + jyqOrBb8;
            int totleNum6 = t_pf1 + t_pf2 + t_pf3 + t_pf4 + t_pf5 + t_pf6 + t_pf7 + t_pf8;
            int totleNum7 = t_qp1 + t_qp2 + t_qp3 + t_qp4 + t_qp5 + t_qp6 + t_qp7 + t_qp8;
            int totleNum8 = t_xz1 + t_xz2 + t_xz3 + t_xz4 + t_xz5 + t_xz6 + t_xz7 + t_xz8;

            if (totleNum1 != 0) {
                t_totle1 = totleNum1 + "";
            }
            if (totleNum2 != 0) {
                t_totle2 = totleNum2 + "";
            }
            if (totleNum3 != 0) {
                t_totle3 = totleNum3 + "";
            }
            if (totleNum4 != 0) {
                t_totle4 = totleNum4 + "";
            }
            if (totleNum5 != 0) {
                t_totle5 = totleNum5 + "";
            }
            if (totleNum6 != 0) {
                t_totle6 = totleNum6 + "";
            }
            if (totleNum7 != 0) {
                t_totle7 = totleNum7 + "";
            }
            if (totleNum8 != 0) {
                t_totle8 = totleNum8 + "";
            }


            //设置 任务单编号
            Row row1 = sheet0.getRow(1);
            Cell row1_cell3 = row1.getCell(3);
            if (!rwdbh.equals("-1")) {
                row1_cell3.setCellValue(rwdbh);
            }

            //设置委托方
            Row row2 = sheet0.getRow(2);
            Cell row2_cell13 = row2.getCell(3);
            if (!"-99".equals(wtf)) {

                if (!"-99".equals(wtfch)) {  //如果二级单位不为空
                    if (wtf.trim().equals(wtfch.trim())) { //如果一级单位和二级单位名称一样
                        row2_cell13.setCellValue(wtf);
                    } else {
                        row2_cell13.setCellValue(wtf + wtfch);
                    }
                } else {
                    row2_cell13.setCellValue(wtf);
                }
            }

            //起止日期
            Row row_rq = sheet0.getRow(3);
            Cell row2_cell1_rq = row_rq.getCell(3);
            if ("".equals(startTimeStr) && "".equals(endTimeStr)) {
            } else {
                String qzreStr = startTimeStr + " - " + endTimeStr;
                row2_cell1_rq.setCellValue(qzreStr);
            }

            //设置面罩检验、气瓶检验、充气、维修
            Row row6 = sheet0.getRow(6);
            //面罩检验
            Cell row6_cell0 = row6.getCell(0);
            if (0 != numberMzJm) {
                row6_cell0.setCellValue(numberMzJm);
            } else {
                row6_cell0.setCellValue(0);
            }
            //气瓶检验
            Cell row6_cell3 = row6.getCell(3);
            if (0 != numberQpJm) {
                row6_cell3.setCellValue(numberQpJm);
            } else {
                row6_cell3.setCellValue(0);
            }
            //充气
            Cell row6_cell6 = row6.getCell(6);
            if (0 != numberQpCqJm) {
                row6_cell6.setCellValue(numberQpCqJm);
            } else {
                row6_cell6.setCellValue(0);
            }
            //维修
            Cell row6_cell9 = row6.getCell(9);
            if (0 != maintenances.size()) {
                row6_cell9.setCellValue(maintenances.size());
            } else {
                row6_cell9.setCellValue(0);
            }

            //品牌名称
            Row row9 = sheet0.getRow(9);
            Cell row9_cell3 = row9.getCell(3);
            row9_cell3.setCellValue(t_mc1);

            Cell row9_cell4 = row9.getCell(4);
            row9_cell4.setCellValue(t_mc2);

            Cell row9_cell5 = row9.getCell(5);
            row9_cell5.setCellValue(t_mc3);

            Cell row9_cell6 = row9.getCell(6);
            row9_cell6.setCellValue(t_mc4);

            Cell row9_cell7 = row9.getCell(7);
            row9_cell7.setCellValue(t_mc5);

            Cell row9_cell8 = row9.getCell(8);
            row9_cell8.setCellValue(t_mc6);

            Cell row9_cell9 = row9.getCell(9);
            row9_cell9.setCellValue(t_mc7);

            Cell row9_cell10 = row9.getCell(10);
            row9_cell10.setCellValue(t_mc8);

            //面罩行
            Row row10 = sheet0.getRow(10);
            Cell row10_cell3 = row10.getCell(3);
            if (!"".equals(t_str_mc1)) {
                row10_cell3.setCellValue(Integer.parseInt(t_str_mc1));
            }

            Cell row10_cell4 = row10.getCell(4);
            if (!"".equals(t_str_mc2)) {
                row10_cell4.setCellValue(Integer.parseInt(t_str_mc2));
            }

            Cell rrow10_cell5 = row10.getCell(5);
            if (!"".equals(t_str_mc3)) {
                rrow10_cell5.setCellValue(Integer.parseInt(t_str_mc3));
            }

            Cell row10_cell6 = row10.getCell(6);
            if (!"".equals(t_str_mc4)) {
                row10_cell6.setCellValue(Integer.parseInt(t_str_mc4));
            }

            Cell row10_cell7 = row10.getCell(7);
            if (!"".equals(t_str_mc5)) {
                row10_cell7.setCellValue(Integer.parseInt(t_str_mc5));
            }

            Cell row10_cell8 = row10.getCell(8);
            if (!"".equals(t_str_mc6)) {
                row10_cell8.setCellValue(Integer.parseInt(t_str_mc6));
            }

            Cell row10_cell9 = row10.getCell(9);
            if (!"".equals(t_str_mc7)) {
                row10_cell9.setCellValue(Integer.parseInt(t_str_mc7));
            }

            Cell row10_cell10 = row10.getCell(10);
            if (!"".equals(t_str_mc8)) {
                row10_cell10.setCellValue(Integer.parseInt(t_str_mc8));
            }

            Cell row10_cell11 = row10.getCell(11);
            if (!"".equals(t_totle1)) {
                row10_cell11.setCellValue(Integer.parseInt(t_totle1));
            }


            //供气阀行
            Row row11 = sheet0.getRow(11);
            Cell row11_cell3 = row11.getCell(3);
            if (!"".equals(t_str_gqf1)) {
                row11_cell3.setCellValue(Integer.parseInt(t_str_gqf1));
            }

            Cell row11_cell4 = row11.getCell(4);
            if (!"".equals(t_str_gqf2)) {
                row11_cell4.setCellValue(Integer.parseInt(t_str_gqf2));
            }

            Cell row11_cell5 = row11.getCell(5);
            if (!"".equals(t_str_gqf3)) {
                row11_cell5.setCellValue(Integer.parseInt(t_str_gqf3));
            }

            Cell row11_cell6 = row11.getCell(6);
            if (!"".equals(t_str_gqf4)) {
                row11_cell6.setCellValue(Integer.parseInt(t_str_gqf4));
            }

            Cell row11_cell7 = row11.getCell(7);
            if (!"".equals(t_str_gqf5)) {
                row11_cell7.setCellValue(Integer.parseInt(t_str_gqf5));
            }

            Cell row11_cell8 = row11.getCell(8);
            if (!"".equals(t_str_gqf6)) {
                row11_cell8.setCellValue(Integer.parseInt(t_str_gqf6));
            }

            Cell row11_cell9 = row11.getCell(9);
            if (!"".equals(t_str_gqf7)) {
                row11_cell9.setCellValue(Integer.parseInt(t_str_gqf7));
            }

            Cell row11_cell10 = row11.getCell(11);
            if (!"".equals(t_str_gqf8)) {
                row11_cell10.setCellValue(Integer.parseInt(t_str_gqf8));
            }
            Cell row11_cell11 = row11.getCell(11);
            if (!"".equals(t_totle2)) {
                row11_cell11.setCellValue(Integer.parseInt(t_totle2));
            }


            //报警器 行
            Row row12 = sheet0.getRow(12);
            Cell row12_cell3 = row12.getCell(3);
            if (!"".equals(t_str_bjq1)) {
                row12_cell3.setCellValue(Integer.parseInt(t_str_bjq1));
            }

            Cell row12_cell4 = row12.getCell(4);
            if (!"".equals(t_str_bjq2)) {
                row12_cell4.setCellValue(Integer.parseInt(t_str_bjq2));
            }

            Cell row12_cell5 = row12.getCell(5);
            if (!"".equals(t_str_bjq3)) {
                row12_cell5.setCellValue(Integer.parseInt(t_str_bjq3));
            }

            Cell row12_cell6 = row12.getCell(6);
            if (!"".equals(t_str_bjq4)) {
                row12_cell6.setCellValue(Integer.parseInt(t_str_bjq4));
            }

            Cell row12_cell7 = row12.getCell(7);
            if (!"".equals(t_str_bjq5)) {
                row12_cell7.setCellValue(Integer.parseInt(t_str_bjq5));
            }

            Cell row12_cell8 = row12.getCell(8);
            if (!"".equals(t_str_bjq6)) {
                row12_cell8.setCellValue(Integer.parseInt(t_str_bjq6));
            }

            Cell row12_cell9 = row12.getCell(9);
            if (!"".equals(t_str_bjq7)) {
                row12_cell9.setCellValue(Integer.parseInt(t_str_bjq7));
            }

            Cell row12_cell10 = row12.getCell(10);
            if (!"".equals(t_str_bjq8)) {
                row12_cell10.setCellValue(Integer.parseInt(t_str_bjq8));
            }

            Cell row12_cell11 = row12.getCell(11);
            if (!"".equals(t_totle3)) {
                row12_cell11.setCellValue(Integer.parseInt(t_totle3));
            }


            //压力表
            Row row13 = sheet0.getRow(13);
            Cell row13_cell3 = row13.getCell(3);
            if (!"".equals(t_str_ylb1)) {
                row13_cell3.setCellValue(Integer.parseInt(t_str_ylb1));
            }

            Cell row13_cell4 = row13.getCell(4);
            if (!"".equals(t_str_ylb2)) {
                row13_cell4.setCellValue(Integer.parseInt(t_str_ylb2));
            }

            Cell row13_cell5 = row13.getCell(5);
            if (!"".equals(t_str_ylb3)) {
                row13_cell5.setCellValue(Integer.parseInt(t_str_ylb3));
            }

            Cell row13_cell6 = row13.getCell(6);
            if (!"".equals(t_str_ylb4)) {
                row13_cell6.setCellValue(Integer.parseInt(t_str_ylb4));
            }

            Cell row13_cell7 = row13.getCell(7);
            if (!"".equals(t_str_ylb5)) {
                row13_cell7.setCellValue(Integer.parseInt(t_str_ylb5));
            }

            Cell row13_cell8 = row13.getCell(8);
            if (!"".equals(t_str_ylb6)) {
                row13_cell8.setCellValue(Integer.parseInt(t_str_ylb6));
            }

            Cell row13_cell9 = row13.getCell(9);
            if (!"".equals(t_str_ylb7)) {
                row13_cell9.setCellValue(Integer.parseInt(t_str_ylb7));
            }

            Cell row13_cell10 = row13.getCell(10);
            if (!"".equals(t_str_ylb8)) {
                row13_cell10.setCellValue(Integer.parseInt(t_str_ylb8));
            }

            Cell row13_cell11 = row13.getCell(11);
            if (!"".equals(t_totle4)) {
                row13_cell11.setCellValue(Integer.parseInt(t_totle4));
            }


            //背具总成 行
            Row row14 = sheet0.getRow(14);
            Cell row14_cell3 = row14.getCell(3);
            if (!"".equals(t_str_jyqOrBb1)) {
                row14_cell3.setCellValue(Integer.parseInt(t_str_jyqOrBb1));
            }

            Cell row14_cell4 = row14.getCell(4);
            if (!"".equals(t_str_jyqOrBb2)) {
                row14_cell4.setCellValue(Integer.parseInt(t_str_jyqOrBb2));
            }

            Cell row14_cell5 = row14.getCell(5);
            if (!"".equals(t_str_jyqOrBb3)) {
                row14_cell5.setCellValue(Integer.parseInt(t_str_jyqOrBb3));
            }

            Cell row14_cell6 = row14.getCell(6);
            if (!"".equals(t_str_jyqOrBb4)) {
                row14_cell6.setCellValue(Integer.parseInt(t_str_jyqOrBb4));
            }

            Cell row14_cell7 = row14.getCell(7);
            if (!"".equals(t_str_jyqOrBb5)) {
                row14_cell7.setCellValue(Integer.parseInt(t_str_jyqOrBb5));
            }

            Cell row14_cell8 = row14.getCell(8);
            if (!"".equals(t_str_jyqOrBb6)) {
                row14_cell8.setCellValue(Integer.parseInt(t_str_jyqOrBb6));
            }

            Cell row14_cell9 = row14.getCell(9);
            if (!"".equals(t_str_jyqOrBb7)) {
                row14_cell9.setCellValue(Integer.parseInt(t_str_jyqOrBb7));
            }

            Cell row14_cell10 = row14.getCell(10);
            if (!"".equals(t_str_jyqOrBb8)) {
                row14_cell10.setCellValue(Integer.parseInt(t_str_jyqOrBb8));
            }

            Cell row14_cell11 = row14.getCell(11);
            if (!"".equals(t_totle5)) {
                row14_cell11.setCellValue(Integer.parseInt(t_totle5));
            }


            //瓶阀行
            Row row15 = sheet0.getRow(15);
            Cell row15_cell3 = row15.getCell(3);
            if (!"".equals(t_str_pf1)) {
                row15_cell3.setCellValue(Integer.parseInt(t_str_pf1));
            }

            Cell row15_cell4 = row15.getCell(4);
            if (!"".equals(t_str_pf2)) {
                row15_cell4.setCellValue(Integer.parseInt(t_str_pf2));
            }

            Cell row15_cell5 = row15.getCell(5);
            if (!"".equals(t_str_pf3)) {
                row15_cell5.setCellValue(Integer.parseInt(t_str_pf3));
            }

            Cell row15_cell6 = row15.getCell(6);
            if (!"".equals(t_str_pf4)) {
                row15_cell6.setCellValue(Integer.parseInt(t_str_pf4));
            }

            Cell row15_cell7 = row15.getCell(7);
            if (!"".equals(t_str_pf5)) {
                row15_cell7.setCellValue(Integer.parseInt(t_str_pf5));
            }

            Cell row15_cell8 = row15.getCell(8);
            if (!"".equals(t_str_pf6)) {
                row15_cell8.setCellValue(Integer.parseInt(t_str_pf6));
            }

            Cell row15_cell9 = row15.getCell(9);
            if (!"".equals(t_str_pf7)) {
                row15_cell9.setCellValue(Integer.parseInt(t_str_pf7));
            }

            Cell row15_cell10 = row15.getCell(10);
            if (!"".equals(t_str_pf8)) {
                row15_cell10.setCellValue(Integer.parseInt(t_str_pf8));
            }

            Cell row15_cell11 = row15.getCell(11);
            if (!"".equals(t_totle6)) {
                row15_cell11.setCellValue(Integer.parseInt(t_totle6));
            }


            //气瓶行
            Row row16 = sheet0.getRow(16);
            Cell row16_cell3 = row16.getCell(3);
            if (!"".equals(t_str_qp1)) {
                row16_cell3.setCellValue(Integer.parseInt(t_str_qp1));
            }

            Cell row16_cell4 = row16.getCell(4);
            if (!"".equals(t_str_qp2)) {
                row16_cell4.setCellValue(Integer.parseInt(t_str_qp2));
            }

            Cell row16_cell5 = row16.getCell(5);
            if (!"".equals(t_str_qp3)) {
                row16_cell5.setCellValue(Integer.parseInt(t_str_qp3));
            }

            Cell row16_cell6 = row16.getCell(6);
            if (!"".equals(t_str_qp4)) {
                row16_cell6.setCellValue(Integer.parseInt(t_str_qp4));
            }

            Cell row16_cell7 = row16.getCell(7);
            if (!"".equals(t_str_qp5)) {
                row16_cell7.setCellValue(Integer.parseInt(t_str_qp5));
            }

            Cell row16_cell8 = row16.getCell(8);
            if (!"".equals(t_str_qp6)) {
                row16_cell8.setCellValue(Integer.parseInt(t_str_qp6));
            }

            Cell row16_cell9 = row16.getCell(9);
            if (!"".equals(t_str_qp7)) {
                row16_cell9.setCellValue(Integer.parseInt(t_str_qp7));
            }

            Cell row16_cell10 = row16.getCell(10);
            if (!"".equals(t_str_qp8)) {
                row16_cell10.setCellValue(Integer.parseInt(t_str_qp8));
            }

            Cell row16_cell11 = row16.getCell(11);
            if (!"".equals(t_totle7)) {
                row16_cell11.setCellValue(Integer.parseInt(t_totle7));
            }


            //箱子行
            Row row17 = sheet0.getRow(17);
            Cell row17_cell3 = row17.getCell(3);
            if (!"".equals(t_str_xz1)) {
                row17_cell3.setCellValue(Integer.parseInt(t_str_xz1));
            }

            Cell row17_cell4 = row17.getCell(4);
            if (!"".equals(t_str_xz2)) {
                row17_cell4.setCellValue(Integer.parseInt(t_str_xz2));
            }

            Cell row17_cell5 = row17.getCell(5);
            if (!"".equals(t_str_xz3)) {
                row17_cell5.setCellValue(Integer.parseInt(t_str_xz3));
            }

            Cell row17_cell6 = row17.getCell(6);
            if (!"".equals(t_str_xz4)) {
                row17_cell6.setCellValue(Integer.parseInt(t_str_xz4));
            }

            Cell row17_cell7 = row17.getCell(7);
            if (!"".equals(t_str_xz5)) {
                row17_cell7.setCellValue(Integer.parseInt(t_str_xz5));
            }

            Cell row17_cell8 = row17.getCell(8);
            if (!"".equals(t_str_xz6)) {
                row17_cell8.setCellValue(Integer.parseInt(t_str_xz6));
            }

            Cell row17_cell9 = row17.getCell(9);
            if (!"".equals(t_str_xz7)) {
                row17_cell9.setCellValue(Integer.parseInt(t_str_xz7));
            }

            Cell row17_cell10 = row17.getCell(10);
            if (!"".equals(t_str_xz8)) {
                row17_cell10.setCellValue(Integer.parseInt(t_str_xz8));
            }

            Cell row17_cell11 = row17.getCell(11);
            if (!"".equals(t_totle8)) {
                row17_cell11.setCellValue(Integer.parseInt(t_totle8));
            }


            long timesss = TimeUtil.currentTimeMillis();
            String fname = TimeUtil.formatTime_6(timesss);
            String fileName = "TJD_" + fname + ".xlsx";
            downLoadExcel(fileName, response, workbook);

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


    /**
     * 下载工作量确认单
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/api/dlGzlqrdQz")
    public void excel2007Export(HttpServletResponse response, HttpServletRequest request, String mbh, long jydwFzrId) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            ClassPathResource cpr = new ClassPathResource("excleTemplate/qzb_gzlqrd.xlsx");
            InputStream is = cpr.getInputStream();
            Workbook workbook = new XSSFWorkbook(is);
            Sheet sheet0 = workbook.getSheetAt(0);

            ReceiptTbBean receiptTbBean = receiptTbMapper.getReceiptByrwdbh(mbh);

            //根据条件号查询 work表
            List<WorkBean> mw = workMapper.getWorkStatistics(mbh, -1, -1, 0, 0, 0);
            //把所有的标识编号都取出来
            List<String> bsbhList = new ArrayList<>();
            for (WorkBean workBean : mw) {
                bsbhList.add(workBean.getBsbh());
            }

//            //根据 任务单编号和类型查询 已完成的报告 面罩的个数统计
//            List<Report> mzNumbers = reportDao.getReportByrwdbh(mbh,1);
//            int numberMzJm=0;
//            for(Report report:mzNumbers){
//                //除去维修替换了 背板/减压器
//                boolean isbh =  report.bsbh.contains("_old");
//                if(!isbh){
//                    numberMzJm++;
//                }
//            }


//            //根据 任务单编号和类型查询 已完成的报告 气瓶的个数统计
//            List<Report> qpNumbers = reportDao.getReportByrwdbh(mbh,2);
//            int numberQpJm=0;
//            for(Report report2:qpNumbers){
//                //除去维修替换了 背板/减压器
//                boolean isbh =  report2.bsbh.contains("_old");
//                if(!isbh){
//                    numberQpJm++;
//                }
//            }
//            //统计充气的气瓶有多少个
//            List<Report> msamples=  reportDao.getReportByrwdbhOrCq(mbh);
//            int numberQpCqJm =0;
//            //维修
//            for(Report mReport:msamples){
//                //除去维修替换了 背板/减压器
//                boolean isbh =  mReport.bsbh.contains("_old");
//                if(!isbh){
//                    numberQpCqJm++;
//                }
//            }

            //然后查询已完成的报告 面罩的个数统计
            List<Report> mzNumbers = reportDao.getReportByBatch(bsbhList, 1);
            int numberMzJm = 0;
            for (Report report : mzNumbers) {
                //除去维修替换了 背板/减压器
                boolean isbh = report.bsbh.contains("_old");
                if (!isbh) {
                    numberMzJm++;
                }
            }

            //根据 任务单编号和类型查询 已完成的报告 气瓶的个数统计
            List<Report> qpNumbers = reportDao.getReportByBatch(bsbhList, 2);
            int numberQpJm = 0;
            for (Report report2 : qpNumbers) {
                //除去维修替换了 背板/减压器
                boolean isbh = report2.bsbh.contains("_old");
                if (!isbh) {
                    numberQpJm++;
                }
            }

            //统计充气的气瓶有多少个
            // List<Report> msamples=  reportDao.getReportByrwdbhOrCqBath(bsbhList);
            List<Sample> msamples = sampleDao.getReportByrwdbhOrCqBath(bsbhList);
            int numberQpCqJm = 0;
            //维修
            for (Sample mSample : msamples) {
                //除去维修替换了 背板/减压器
                boolean isbh = mSample.bsbh.contains("_old");
                if (!isbh) {
                    numberQpCqJm++;
                }
            }

            //查询维修个数
            List<Maintenance> maintenances = maintenanceDao.getMaintenanceByRwdbh(mbh);
            HashSet<String> bjmcSet = new HashSet<String>();
            for (Maintenance maiobj : maintenances) {

                if (!"".equals(maiobj.mzGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.mzGhbjpp);
                    }
                }
                if (!"".equals(maiobj.gqfGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.gqfGhbjpp);
                    }
                }
                if (!"".equals(maiobj.bjqGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.bjqGhbjpp);
                    }
                }
                if (!"".equals(maiobj.ylbGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.ylbGhbjpp);
                    }
                }
                if (!"".equals(maiobj.jyqGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.jyqGhbjpp);
                    }
                }
                if (!"".equals(maiobj.bbGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.bbGhbjpp);
                    }
                }
                if (!"".equals(maiobj.pfGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.pfGhbjpp);
                    }
                }
                if (!"".equals(maiobj.qpGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.qpGhbjpp);
                    }
                }
                if (!"".equals(maiobj.xzGhbjpp)) {
                    if (bjmcSet.size() < 8) {
                        bjmcSet.add(maiobj.xzGhbjpp);
                    }
                }
            }


            //名牌名称
            String t_mc1 = "";
            String t_mc2 = "";
            String t_mc3 = "";
            String t_mc4 = "";
            String t_mc5 = "";
            String t_mc6 = "";
            String t_mc7 = "";
            String t_mc8 = "";

            //第一行
            int t_mz1 = 0;
            int t_mz2 = 0;
            int t_mz3 = 0;
            int t_mz4 = 0;
            int t_mz5 = 0;
            int t_mz6 = 0;
            int t_mz7 = 0;
            int t_mz8 = 0;
            String t_str_mc1 = "";
            String t_str_mc2 = "";
            String t_str_mc3 = "";
            String t_str_mc4 = "";
            String t_str_mc5 = "";
            String t_str_mc6 = "";
            String t_str_mc7 = "";
            String t_str_mc8 = "";

            //第二行
            int t_gqf1 = 0;
            int t_gqf2 = 0;
            int t_gqf3 = 0;
            int t_gqf4 = 0;
            int t_gqf5 = 0;
            int t_gqf6 = 0;
            int t_gqf7 = 0;
            int t_gqf8 = 0;
            String t_str_gqf1 = "";
            String t_str_gqf2 = "";
            String t_str_gqf3 = "";
            String t_str_gqf4 = "";
            String t_str_gqf5 = "";
            String t_str_gqf6 = "";
            String t_str_gqf7 = "";
            String t_str_gqf8 = "";

            //第三行
            int t_bjq1 = 0;
            int t_bjq2 = 0;
            int t_bjq3 = 0;
            int t_bjq4 = 0;
            int t_bjq5 = 0;
            int t_bjq6 = 0;
            int t_bjq7 = 0;
            int t_bjq8 = 0;
            String t_str_bjq1 = "";
            String t_str_bjq2 = "";
            String t_str_bjq3 = "";
            String t_str_bjq4 = "";
            String t_str_bjq5 = "";
            String t_str_bjq6 = "";
            String t_str_bjq7 = "";
            String t_str_bjq8 = "";

            //第四行
            int t_ylb1 = 0;
            int t_ylb2 = 0;
            int t_ylb3 = 0;
            int t_ylb4 = 0;
            int t_ylb5 = 0;
            int t_ylb6 = 0;
            int t_ylb7 = 0;
            int t_ylb8 = 0;
            String t_str_ylb1 = "";
            String t_str_ylb2 = "";
            String t_str_ylb3 = "";
            String t_str_ylb4 = "";
            String t_str_ylb5 = "";
            String t_str_ylb6 = "";
            String t_str_ylb7 = "";
            String t_str_ylb8 = "";


            //第五行
            //减压器的
            int t_jyq1 = 0;
            int t_jyq2 = 0;
            int t_jyq3 = 0;
            int t_jyq4 = 0;
            int t_jyq5 = 0;
            int t_jyq6 = 0;
            int t_jyq7 = 0;
            int t_jyq8 = 0;
            //背板的
            int t_bb1 = 0;
            int t_bb2 = 0;
            int t_bb3 = 0;
            int t_bb4 = 0;
            int t_bb5 = 0;
            int t_bb6 = 0;
            int t_bb7 = 0;
            int t_bb8 = 0;
            String t_str_jyqOrBb1 = "";
            String t_str_jyqOrBb2 = "";
            String t_str_jyqOrBb3 = "";
            String t_str_jyqOrBb4 = "";
            String t_str_jyqOrBb5 = "";
            String t_str_jyqOrBb6 = "";
            String t_str_jyqOrBb7 = "";
            String t_str_jyqOrBb8 = "";


            //第六行
            int t_pf1 = 0;
            int t_pf2 = 0;
            int t_pf3 = 0;
            int t_pf4 = 0;
            int t_pf5 = 0;
            int t_pf6 = 0;
            int t_pf7 = 0;
            int t_pf8 = 0;
            String t_str_pf1 = "";
            String t_str_pf2 = "";
            String t_str_pf3 = "";
            String t_str_pf4 = "";
            String t_str_pf5 = "";
            String t_str_pf6 = "";
            String t_str_pf7 = "";
            String t_str_pf8 = "";

            //第7行
            String t_str_qp1 = "";
            String t_str_qp2 = "";
            String t_str_qp3 = "";
            String t_str_qp4 = "";
            String t_str_qp5 = "";
            String t_str_qp6 = "";
            String t_str_qp7 = "";
            String t_str_qp8 = "";
            int t_qp1 = 0;
            int t_qp2 = 0;
            int t_qp3 = 0;
            int t_qp4 = 0;
            int t_qp5 = 0;
            int t_qp6 = 0;
            int t_qp7 = 0;
            int t_qp8 = 0;

            //第八行
            int t_xz1 = 0;
            int t_xz2 = 0;
            int t_xz3 = 0;
            int t_xz4 = 0;
            int t_xz5 = 0;
            int t_xz6 = 0;
            int t_xz7 = 0;
            int t_xz8 = 0;
            String t_str_xz1 = "";
            String t_str_xz2 = "";
            String t_str_xz3 = "";
            String t_str_xz4 = "";
            String t_str_xz5 = "";
            String t_str_xz6 = "";
            String t_str_xz7 = "";
            String t_str_xz8 = "";

            //总数
            String t_totle1 = "";
            String t_totle2 = "";
            String t_totle3 = "";
            String t_totle4 = "";
            String t_totle5 = "";
            String t_totle6 = "";
            String t_totle7 = "";
            String t_totle8 = "";

            //把set转list
            List<String> setList = new ArrayList<String>(bjmcSet);
            //把品牌都设置到部件名称框里面
            for (int k = 0; k < setList.size(); k++) {
                switch (k) {
                    case 0:
                        t_mc1 = setList.get(k);
                        break;
                    case 1:
                        t_mc2 = setList.get(k);
                        break;
                    case 2:
                        t_mc3 = setList.get(k);
                        break;
                    case 3:
                        t_mc4 = setList.get(k);
                        break;
                    case 4:
                        t_mc5 = setList.get(k);
                        break;
                    case 5:
                        t_mc6 = setList.get(k);
                        break;
                    case 6:
                        t_mc7 = setList.get(k);
                        break;
                    case 7:
                        t_mc8 = setList.get(k);
                        break;
                }
            }

            for (int c = 0; c < maintenances.size(); c++) {
                Maintenance mobj = maintenances.get(c);
                //第一行--------------------------------------------------------------------------------------
                if (mobj.mzGhbjpp.equals(t_mc1) && !"".equals(t_mc1)) {
                    t_mz1 = t_mz1 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc2) && !"".equals(t_mc2)) {
                    t_mz2 = t_mz2 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc3) && !"".equals(t_mc3)) {
                    t_mz3 = t_mz3 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc4) && !"".equals(t_mc4)) {
                    t_mz4 = t_mz4 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc5) && !"".equals(t_mc5)) {
                    t_mz5 = t_mz5 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc6) && !"".equals(t_mc6)) {
                    t_mz6 = t_mz6 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc7) && !"".equals(t_mc7)) {
                    t_mz7 = t_mz7 + 1;
                }
                if (mobj.mzGhbjpp.equals(t_mc8) && !"".equals(t_mc8)) {
                    t_mz8 = t_mz8 + 1;
                }


                //第二行--------------------------------------------------------------------------------------
                if (mobj.gqfGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_gqf1 = t_gqf1 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_gqf2 = t_gqf2 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_gqf3 = t_gqf3 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_gqf4 = t_gqf4 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_gqf5 = t_gqf5 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_gqf6 = t_gqf6 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_gqf7 = t_gqf7 + 1;
                }
                if (mobj.gqfGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_gqf8 = t_gqf8 + 1;
                }

                //第三行--------------------------------------------------------------------------------------
                if (mobj.bjqGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_bjq1 = t_bjq1 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_bjq2 = t_bjq2 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_bjq3 = t_bjq3 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_bjq4 = t_bjq4 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_bjq5 = t_bjq5 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_bjq6 = t_bjq6 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_bjq7 = t_bjq7 + 1;
                }
                if (mobj.bjqGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_bjq8 = t_bjq8 + 1;
                }


                //第四行--------------------------------------------------------------------------------------
                if (mobj.ylbGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_ylb1 = t_ylb1 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_ylb2 = t_ylb2 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_ylb3 = t_ylb3 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_ylb4 = t_ylb4 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_ylb5 = t_ylb5 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_ylb6 = t_ylb6 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_ylb7 = t_ylb7 + 1;
                }
                if (mobj.ylbGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_ylb8 = t_ylb8 + 1;
                }


                //第五行--------------------------------------------------------------------------------------
                //减压器
                if (mobj.jyqGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_jyq1 = t_jyq1 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_jyq2 = t_jyq2 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_jyq3 = t_jyq3 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_jyq4 = t_jyq4 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_jyq5 = t_jyq5 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_jyq6 = t_jyq6 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_jyq7 = t_jyq7 + 1;
                }
                if (mobj.jyqGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_jyq8 = t_jyq8 + 1;
                }
                //背板
                if (mobj.bbGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_bb1 = t_bb1 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_bb2 = t_bb2 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_bb3 = t_bb3 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_bb4 = t_bb4 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_bb5 = t_bb5 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_bb6 = t_bb6 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_bb7 = t_bb7 + 1;
                }
                if (mobj.bbGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_bb8 = t_bb8 + 1;
                }


                //第六行--------------------------------------------------------------------------------------
                if (mobj.pfGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_pf1 = t_pf1 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_pf2 = t_pf2 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_pf3 = t_pf3 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_pf4 = t_pf4 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_pf5 = t_pf5 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_pf6 = t_pf6 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_pf7 = t_pf7 + 1;
                }
                if (mobj.pfGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_pf8 = t_pf8 + 1;
                }

                //第七行--------------------------------------------------------------------------------------
                if (mobj.qpGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_qp1 = t_qp1 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_qp2 = t_qp2 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_qp3 = t_qp3 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_qp4 = t_qp4 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_qp5 = t_qp5 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_qp6 = t_qp6 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_qp7 = t_qp7 + 1;
                }
                if (mobj.qpGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_qp8 = t_qp8 + 1;
                }


                //第八行--------------------------------------------------------------------------------------
                if (mobj.xzGhbjpp.equals(t_mc1) && !t_mc1.equals("")) {
                    t_xz1 = t_xz1 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc2) && !t_mc2.equals("")) {
                    t_xz2 = t_xz2 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc3) && !t_mc3.equals("")) {
                    t_xz3 = t_xz3 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc4) && !t_mc4.equals("")) {
                    t_xz4 = t_xz4 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc5) && !t_mc5.equals("")) {
                    t_xz5 = t_xz5 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc6) && !t_mc6.equals("")) {
                    t_xz6 = t_xz6 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc7) && !t_mc7.equals("")) {
                    t_xz7 = t_xz7 + 1;
                }
                if (mobj.xzGhbjpp.equals(t_mc8) && !t_mc8.equals("")) {
                    t_xz8 = t_xz8 + 1;
                }
            }


            //第一行的值---------------------------------------------------------------------------------------------
            if (t_mz1 != 0) {
                t_str_mc1 = t_mz1 + "";
            }
            if (t_mz2 != 0) {
                t_str_mc2 = t_mz2 + "";
            }
            if (t_mz3 != 0) {
                t_str_mc3 = t_mz3 + "";
            }
            if (t_mz4 != 0) {
                t_str_mc4 = t_mz4 + "";
            }
            if (t_mz5 != 0) {
                t_str_mc5 = t_mz5 + "";
            }
            if (t_mz6 != 0) {
                t_str_mc6 = t_mz6 + "";
            }
            if (t_mz7 != 0) {
                t_str_mc7 = t_mz7 + "";
            }
            if (t_mz8 != 0) {
                t_str_mc8 = t_mz8 + "";
            }


            //第二行的值---------------------------------------------------------------------------------------------
            if (t_gqf1 != 0) {
                t_str_gqf1 = t_gqf1 + "";
            }
            if (t_gqf2 != 0) {
                t_str_gqf2 = t_gqf2 + "";
            }
            if (t_gqf3 != 0) {
                t_str_gqf3 = t_gqf3 + "";
            }
            if (t_gqf4 != 0) {
                t_str_gqf4 = t_gqf4 + "";
            }
            if (t_gqf5 != 0) {
                t_str_gqf5 = t_gqf5 + "";
            }
            if (t_gqf6 != 0) {
                t_str_gqf6 = t_gqf6 + "";
            }
            if (t_gqf7 != 0) {
                t_str_gqf7 = t_gqf7 + "";
            }
            if (t_gqf8 != 0) {
                t_str_gqf8 = t_gqf8 + "";
            }

            //第三行的值---------------------------------------------------------------------------------------------
            if (t_bjq1 != 0) {
                t_str_bjq1 = t_bjq1 + "";
            }
            if (t_bjq2 != 0) {
                t_str_bjq2 = t_bjq2 + "";
            }
            if (t_bjq3 != 0) {
                t_str_bjq3 = t_bjq3 + "";
            }
            if (t_bjq4 != 0) {
                t_str_bjq4 = t_bjq4 + "";
            }
            if (t_bjq5 != 0) {
                t_str_bjq5 = t_bjq5 + "";
            }
            if (t_bjq6 != 0) {
                t_str_bjq6 = t_bjq6 + "";
            }
            if (t_bjq7 != 0) {
                t_str_bjq7 = t_bjq7 + "";
            }
            if (t_bjq8 != 0) {
                t_str_bjq8 = t_bjq8 + "";
            }


            //第四行的值---------------------------------------------------------------------------------------------
            if (t_ylb1 != 0) {
                t_str_ylb1 = t_ylb1 + "";
            }
            if (t_ylb2 != 0) {
                t_str_ylb2 = t_ylb2 + "";
            }
            if (t_ylb3 != 0) {
                t_str_ylb3 = t_ylb3 + "";
            }
            if (t_ylb4 != 0) {
                t_str_ylb4 = t_ylb4 + "";
            }
            if (t_ylb5 != 0) {
                t_str_ylb5 = t_ylb5 + "";
            }
            if (t_ylb6 != 0) {
                t_str_ylb6 = t_ylb6 + "";
            }
            if (t_ylb7 != 0) {
                t_str_ylb7 = t_ylb7 + "";
            }
            if (t_ylb8 != 0) {
                t_str_ylb8 = t_ylb8 + "";
            }

            //第五行的值---------------------------------------------------------------------------------------------
            //将减压器和背板的数量加起来 才是背具总成
//            int jyqOrBb1 = t_jyq1 + t_bb1;
//            int jyqOrBb2 = t_jyq2 + t_bb2;
//            int jyqOrBb3 = t_jyq3 + t_bb3;
//            int jyqOrBb4 = t_jyq4 + t_bb4;
//            int jyqOrBb5 = t_jyq5 + t_bb5;
//            int jyqOrBb6 = t_jyq6 + t_bb6;
//            int jyqOrBb7 = t_jyq7 + t_bb7;
//            int jyqOrBb8 = t_jyq8 + t_bb8;

            int jyqOrBb1 = t_jyq1;
            int jyqOrBb2 = t_jyq2;
            int jyqOrBb3 = t_jyq3;
            int jyqOrBb4 = t_jyq4;
            int jyqOrBb5 = t_jyq5;
            int jyqOrBb6 = t_jyq6;
            int jyqOrBb7 = t_jyq7;
            int jyqOrBb8 = t_jyq8;


            //背板
            if (jyqOrBb1 != 0) {
                t_str_jyqOrBb1 = jyqOrBb1 + "";
            }
            if (jyqOrBb2 != 0) {
                t_str_jyqOrBb2 = jyqOrBb2 + "";
            }
            if (jyqOrBb3 != 0) {
                t_str_jyqOrBb3 = jyqOrBb3 + "";
            }
            if (jyqOrBb4 != 0) {
                t_str_jyqOrBb4 = jyqOrBb4 + "";
            }
            if (jyqOrBb5 != 0) {
                t_str_jyqOrBb5 = jyqOrBb5 + "";
            }
            if (jyqOrBb6 != 0) {
                t_str_jyqOrBb6 = jyqOrBb6 + "";
            }
            if (jyqOrBb7 != 0) {
                t_str_jyqOrBb7 = jyqOrBb7 + "";
            }
            if (jyqOrBb8 != 0) {
                t_str_jyqOrBb8 = jyqOrBb8 + "";
            }

            //第六行的值---------------------------------------------------------------------------------------------
            if (t_pf1 != 0) {
                t_str_pf1 = t_pf1 + "";
            }
            if (t_pf2 != 0) {
                t_str_pf2 = t_pf2 + "";
            }
            if (t_pf3 != 0) {
                t_str_pf3 = t_pf3 + "";
            }
            if (t_pf4 != 0) {
                t_str_pf4 = t_pf4 + "";
            }
            if (t_pf5 != 0) {
                t_str_pf5 = t_pf5 + "";
            }
            if (t_pf6 != 0) {
                t_str_pf6 = t_pf6 + "";
            }
            if (t_pf7 != 0) {
                t_str_pf7 = t_pf7 + "";
            }
            if (t_pf8 != 0) {
                t_str_pf8 = t_pf8 + "";
            }


            //第七行的值---------------------------------------------------------------------------------------------
            if (t_qp1 != 0) {
                t_str_qp1 = t_qp1 + "";
            }
            if (t_qp2 != 0) {
                t_str_qp2 = t_qp2 + "";
            }
            if (t_qp3 != 0) {
                t_str_qp3 = t_qp3 + "";
            }
            if (t_qp4 != 0) {
                t_str_qp4 = t_qp4 + "";
            }
            if (t_qp5 != 0) {
                t_str_qp5 = t_qp5 + "";
            }
            if (t_qp6 != 0) {
                t_str_qp6 = t_qp6 + "";
            }
            if (t_qp7 != 0) {
                t_str_qp7 = t_qp7 + "";
            }
            if (t_qp8 != 0) {
                t_str_qp8 = t_qp8 + "";
            }

            //第八行的值---------------------------------------------------------------------------------------------
            if (t_xz1 != 0) {
                t_str_xz1 = t_xz1 + "";
            }
            if (t_xz2 != 0) {
                t_str_xz2 = t_xz2 + "";
            }
            if (t_xz3 != 0) {
                t_str_xz3 = t_xz3 + "";
            }
            if (t_xz4 != 0) {
                t_str_xz4 = t_xz4 + "";
            }
            if (t_xz5 != 0) {
                t_str_xz5 = t_xz5 + "";
            }
            if (t_xz6 != 0) {
                t_str_xz6 = t_xz6 + "";
            }
            if (t_xz7 != 0) {
                t_str_xz7 = t_xz7 + "";
            }
            if (t_xz8 != 0) {
                t_str_xz8 = t_xz8 + "";
            }

            int totleNum1 = t_mz1 + t_mz2 + t_mz3 + t_mz4 + t_mz5 + t_mz6 + t_mz7 + t_mz8;
            int totleNum2 = t_gqf1 + t_gqf2 + t_gqf3 + t_gqf4 + t_gqf5 + t_gqf6 + t_gqf7 + t_gqf8;
            int totleNum3 = t_bjq1 + t_bjq2 + t_bjq3 + t_bjq4 + t_bjq5 + t_bjq6 + t_bjq7 + t_bjq8;
            int totleNum4 = t_ylb1 + t_ylb2 + t_ylb3 + t_ylb4 + t_ylb5 + t_ylb6 + t_ylb7 + t_ylb8;
            int totleNum5 = jyqOrBb1 + jyqOrBb2 + jyqOrBb3 + jyqOrBb4 + jyqOrBb5 + jyqOrBb6 + jyqOrBb7 + jyqOrBb8;
            int totleNum6 = t_pf1 + t_pf2 + t_pf3 + t_pf4 + t_pf5 + t_pf6 + t_pf7 + t_pf8;
            int totleNum7 = t_qp1 + t_qp2 + t_qp3 + t_qp4 + t_qp5 + t_qp6 + t_qp7 + t_qp8;
            int totleNum8 = t_xz1 + t_xz2 + t_xz3 + t_xz4 + t_xz5 + t_xz6 + t_xz7 + t_xz8;

            if (totleNum1 != 0) {
                t_totle1 = totleNum1 + "";
            }
            if (totleNum2 != 0) {
                t_totle2 = totleNum2 + "";
            }
            if (totleNum3 != 0) {
                t_totle3 = totleNum3 + "";
            }
            if (totleNum4 != 0) {
                t_totle4 = totleNum4 + "";
            }
            if (totleNum5 != 0) {
                t_totle5 = totleNum5 + "";
            }
            if (totleNum6 != 0) {
                t_totle6 = totleNum6 + "";
            }
            if (totleNum7 != 0) {
                t_totle7 = totleNum7 + "";
            }
            if (totleNum8 != 0) {
                t_totle8 = totleNum8 + "";
            }


            //设置 任务单编号
            Row row1 = sheet0.getRow(1);
            Cell row1_cell3 = row1.getCell(3);
            row1_cell3.setCellValue(receiptTbBean.getRwdbh());

            //设置委托方
            Row row2 = sheet0.getRow(2);
            Cell row2_cell13 = row2.getCell(3);

            if (receiptTbBean.getWtfchId() != 0) { //如果二级单位不为空
                if (receiptTbBean.getWtf().trim().equals(receiptTbBean.getWtfch().trim())) { //如果一级单位和二级单位名字一样
                    row2_cell13.setCellValue(receiptTbBean.getWtf());
                } else {
                    row2_cell13.setCellValue(receiptTbBean.getWtf() + receiptTbBean.getWtfch());
                }
            } else {
                row2_cell13.setCellValue(receiptTbBean.getWtf());
            }

            Row row3 = sheet0.getRow(3);
            Cell row3_cell0 = row3.getCell(3);
            if ("".equals(receiptTbBean.getEndNumber())) {
                row3_cell0.setCellValue(receiptTbBean.getStartNumber());
            } else {
                row3_cell0.setCellValue(receiptTbBean.getStartNumber() + "- " + receiptTbBean.getEndNumber());
            }

            Cell row9_cell1 = row3.getCell(9);
            row9_cell1.setCellValue(receiptTbBean.getJsrq());


            //面罩检验

            //设置面罩检验、气瓶检验、充气、维修
            Row row6 = sheet0.getRow(6);
            //面罩检验
            Cell row6_cell0 = row6.getCell(0);
            if (0 != numberMzJm) {
                row6_cell0.setCellValue(numberMzJm);
            } else {
                row6_cell0.setCellValue(0);
            }

            //气瓶检验
            Cell row6_cell3 = row6.getCell(3);
            if (0 != numberQpJm) {
                row6_cell3.setCellValue(numberQpJm);
            } else {
                row6_cell3.setCellValue(0);
            }
            //充气
            Cell row6_cell6 = row6.getCell(6);
            if (0 != numberQpCqJm) {
                row6_cell6.setCellValue(numberQpCqJm);
            } else {
                row6_cell6.setCellValue(0);
            }

            //维修
            Cell row6_cell9 = row6.getCell(9);
            if (0 != maintenances.size()) {
                row6_cell9.setCellValue(maintenances.size());
            } else {
                row6_cell9.setCellValue(0);
            }


            //品牌名称
            Row row9 = sheet0.getRow(9);
            Cell row9_cell3 = row9.getCell(3);
            row9_cell3.setCellValue(t_mc1);

            Cell row9_cell4 = row9.getCell(4);
            row9_cell4.setCellValue(t_mc2);

            Cell row9_cell5 = row9.getCell(5);
            row9_cell5.setCellValue(t_mc3);

            Cell row9_cell6 = row9.getCell(6);
            row9_cell6.setCellValue(t_mc4);

            Cell row9_cell7 = row9.getCell(7);
            row9_cell7.setCellValue(t_mc5);

            Cell row9_cell8 = row9.getCell(8);
            row9_cell8.setCellValue(t_mc6);

            Cell row9_cell9 = row9.getCell(9);
            row9_cell9.setCellValue(t_mc7);

            Cell row9_cell10 = row9.getCell(10);
            row9_cell10.setCellValue(t_mc8);


            //面罩行
            Row row10 = sheet0.getRow(10);
            Cell row10_cell3 = row10.getCell(3);
            if (!"".equals(t_str_mc1)) {
                row10_cell3.setCellValue(Integer.parseInt(t_str_mc1));
            }

            Cell row10_cell4 = row10.getCell(4);
            if (!"".equals(t_str_mc2)) {
                row10_cell4.setCellValue(Integer.parseInt(t_str_mc2));
            }

            Cell row10_cell5 = row10.getCell(5);
            if (!"".equals(t_str_mc3)) {
                row10_cell5.setCellValue(Integer.parseInt(t_str_mc3));
            }

            Cell row10_cell6 = row10.getCell(6);
            if (!"".equals(t_str_mc4)) {
                row10_cell6.setCellValue(Integer.parseInt(t_str_mc4));
            }

            Cell row10_cell7 = row10.getCell(7);
            if (!"".equals(t_str_mc5)) {
                row10_cell7.setCellValue(Integer.parseInt(t_str_mc5));
            }

            Cell row10_cell8 = row10.getCell(8);
            if (!"".equals(t_str_mc6)) {
                row10_cell8.setCellValue(Integer.parseInt(t_str_mc6));
            }

            Cell row10_cell9 = row10.getCell(9);
            if (!"".equals(t_str_mc7)) {
                row10_cell9.setCellValue(Integer.parseInt(t_str_mc7));
            }

            Cell row10_cell10 = row10.getCell(10);
            if (!"".equals(t_str_mc8)) {
                row10_cell10.setCellValue(Integer.parseInt(t_str_mc8));
            }

            Cell row10_cell11 = row10.getCell(11);
            if (!"".equals(t_totle1)) {
                row10_cell11.setCellValue(Integer.parseInt(t_totle1));
            }


            //供气阀行
            Row row11 = sheet0.getRow(11);
            Cell row11_cell3 = row11.getCell(3);
            if (!"".equals(t_str_gqf1)) {
                row11_cell3.setCellValue(Integer.parseInt(t_str_gqf1));
            }

            Cell row11_cell4 = row11.getCell(4);
            if (!"".equals(t_str_gqf2)) {
                row11_cell4.setCellValue(Integer.parseInt(t_str_gqf2));
            }

            Cell row11_cell5 = row11.getCell(5);
            if (!"".equals(t_str_gqf3)) {
                row11_cell5.setCellValue(Integer.parseInt(t_str_gqf3));
            }

            Cell row11_cell6 = row11.getCell(6);
            if (!"".equals(t_str_gqf4)) {
                row11_cell6.setCellValue(Integer.parseInt(t_str_gqf4));
            }

            Cell row11_cell7 = row11.getCell(7);
            if (!"".equals(t_str_gqf5)) {
                row11_cell7.setCellValue(Integer.parseInt(t_str_gqf5));
            }

            Cell row11_cell8 = row11.getCell(8);
            if (!"".equals(t_str_gqf6)) {
                row11_cell8.setCellValue(Integer.parseInt(t_str_gqf6));
            }

            Cell row11_cell9 = row11.getCell(9);
            if (!"".equals(t_str_gqf7)) {
                row11_cell9.setCellValue(Integer.parseInt(t_str_gqf7));
            }

            Cell row11_cell10 = row11.getCell(10);
            if (!"".equals(t_str_gqf8)) {
                row11_cell10.setCellValue(Integer.parseInt(t_str_gqf8));
            }

            Cell row11_cell11 = row11.getCell(11);
            if (!"".equals(t_totle2)) {
                row11_cell11.setCellValue(Integer.parseInt(t_totle2));
            }


            //报警器 行
            Row row12 = sheet0.getRow(12);
            Cell row12_cell3 = row12.getCell(3);
            if (!"".equals(t_str_bjq1)) {
                row12_cell3.setCellValue(Integer.parseInt(t_str_bjq1));
            }

            Cell row12_cell4 = row12.getCell(4);
            if (!"".equals(t_str_bjq2)) {
                row12_cell4.setCellValue(Integer.parseInt(t_str_bjq2));
            }

            Cell row12_cell5 = row12.getCell(5);
            if (!"".equals(t_str_bjq3)) {
                row12_cell5.setCellValue(Integer.parseInt(t_str_bjq3));
            }

            Cell row12_cell6 = row12.getCell(6);
            if (!"".equals(t_str_bjq4)) {
                row12_cell6.setCellValue(Integer.parseInt(t_str_bjq4));
            }

            Cell row12_cell7 = row12.getCell(7);
            if (!"".equals(t_str_bjq5)) {
                row12_cell7.setCellValue(Integer.parseInt(t_str_bjq5));
            }

            Cell row12_cell8 = row12.getCell(8);
            if (!"".equals(t_str_bjq6)) {
                row12_cell8.setCellValue(Integer.parseInt(t_str_bjq6));
            }

            Cell row12_cell9 = row12.getCell(9);
            if (!"".equals(t_str_bjq7)) {
                row12_cell9.setCellValue(Integer.parseInt(t_str_bjq7));
            }

            Cell row12_cell10 = row12.getCell(10);
            if (!"".equals(t_str_bjq8)) {
                row12_cell10.setCellValue(Integer.parseInt(t_str_bjq8));
            }

            Cell row12_cell11 = row12.getCell(11);
            if (!"".equals(t_totle3)) {
                row12_cell11.setCellValue(Integer.parseInt(t_totle3));
            }


            //压力表
            Row row13 = sheet0.getRow(13);
            Cell row13_cell3 = row13.getCell(3);
            if (!"".equals(t_str_ylb1)) {
                row13_cell3.setCellValue(Integer.parseInt(t_str_ylb1));
            }

            Cell row13_cell4 = row13.getCell(4);
            if (!"".equals(t_str_ylb2)) {
                row13_cell4.setCellValue(Integer.parseInt(t_str_ylb2));
            }

            Cell row13_cell5 = row13.getCell(5);
            if (!"".equals(t_str_ylb3)) {
                row13_cell5.setCellValue(Integer.parseInt(t_str_ylb3));
            }

            Cell row13_cell6 = row13.getCell(6);
            if (!"".equals(t_str_ylb4)) {
                row13_cell6.setCellValue(Integer.parseInt(t_str_ylb4));
            }

            Cell row13_cell7 = row13.getCell(7);
            if (!"".equals(t_str_ylb5)) {
                row13_cell7.setCellValue(Integer.parseInt(t_str_ylb5));
            }

            Cell row13_cell8 = row13.getCell(8);
            if (!"".equals(t_str_ylb6)) {
                row13_cell8.setCellValue(Integer.parseInt(t_str_ylb6));
            }

            Cell row13_cell9 = row13.getCell(9);
            if (!"".equals(t_str_ylb7)) {
                row13_cell9.setCellValue(Integer.parseInt(t_str_ylb7));
            }

            Cell row13_cell10 = row13.getCell(10);
            if (!"".equals(t_str_ylb8)) {
                row13_cell10.setCellValue(Integer.parseInt(t_str_ylb8));
            }

            Cell row13_cell11 = row13.getCell(11);
            if (!"".equals(t_totle4)) {
                row13_cell11.setCellValue(Integer.parseInt(t_totle4));
            }


            //背具总成 行
            Row row14 = sheet0.getRow(14);
            Cell row14_cell3 = row14.getCell(3);
            if (!"".equals(t_str_jyqOrBb1)) {
                row14_cell3.setCellValue(Integer.parseInt(t_str_jyqOrBb1));
            }

            Cell row14_cell4 = row14.getCell(4);
            if (!"".equals(t_str_jyqOrBb2)) {
                row14_cell4.setCellValue(Integer.parseInt(t_str_jyqOrBb2));
            }

            Cell row14_cell5 = row14.getCell(5);
            if (!"".equals(t_str_jyqOrBb3)) {
                row14_cell5.setCellValue(Integer.parseInt(t_str_jyqOrBb3));
            }

            Cell row14_cell6 = row14.getCell(6);
            if (!"".equals(t_str_jyqOrBb4)) {
                row14_cell6.setCellValue(Integer.parseInt(t_str_jyqOrBb4));
            }

            Cell row14_cell7 = row14.getCell(7);
            if (!"".equals(t_str_jyqOrBb5)) {
                row14_cell7.setCellValue(Integer.parseInt(t_str_jyqOrBb5));
            }

            Cell row14_cell8 = row14.getCell(8);
            if (!"".equals(t_str_jyqOrBb6)) {
                row14_cell8.setCellValue(Integer.parseInt(t_str_jyqOrBb6));
            }

            Cell row14_cell9 = row14.getCell(9);
            if (!"".equals(t_str_jyqOrBb7)) {
                row14_cell9.setCellValue(Integer.parseInt(t_str_jyqOrBb7));
            }

            Cell row14_cell10 = row14.getCell(10);
            if (!"".equals(t_str_jyqOrBb8)) {
                row14_cell10.setCellValue(Integer.parseInt(t_str_jyqOrBb8));
            }

            Cell row14_cell11 = row14.getCell(11);
            if (!"".equals(t_totle5)) {
                row14_cell11.setCellValue(Integer.parseInt(t_totle5));
            }


            //瓶阀行
            Row row15 = sheet0.getRow(15);
            Cell row15_cell3 = row15.getCell(3);
            if (!"".equals(t_str_pf1)) {
                row15_cell3.setCellValue(Integer.parseInt(t_str_pf1));
            }

            Cell row15_cell4 = row15.getCell(4);
            if (!"".equals(t_str_pf2)) {
                row15_cell4.setCellValue(Integer.parseInt(t_str_pf2));
            }

            Cell row15_cell5 = row15.getCell(5);
            if (!"".equals(t_str_pf3)) {
                row15_cell5.setCellValue(Integer.parseInt(t_str_pf3));
            }

            Cell row15_cell6 = row15.getCell(6);
            if (!"".equals(t_str_pf4)) {
                row15_cell6.setCellValue(Integer.parseInt(t_str_pf4));
            }

            Cell row15_cell7 = row15.getCell(7);
            if (!"".equals(t_str_pf5)) {
                row15_cell7.setCellValue(Integer.parseInt(t_str_pf5));
            }

            Cell row15_cell8 = row15.getCell(8);
            if (!"".equals(t_str_pf6)) {
                row15_cell8.setCellValue(Integer.parseInt(t_str_pf6));
            }

            Cell row15_cell9 = row15.getCell(9);
            if (!"".equals(t_str_pf7)) {
                row15_cell9.setCellValue(Integer.parseInt(t_str_pf7));
            }

            Cell row15_cell10 = row15.getCell(10);
            if (!"".equals(t_str_pf8)) {
                row15_cell10.setCellValue(Integer.parseInt(t_str_pf8));
            }

            Cell row15_cell11 = row15.getCell(11);
            if (!"".equals(t_totle6)) {
                row15_cell11.setCellValue(Integer.parseInt(t_totle6));
            }


            //气瓶行
            Row row16 = sheet0.getRow(16);
            Cell row16_cell3 = row16.getCell(3);
            if (!"".equals(t_str_qp1)) {
                row16_cell3.setCellValue(Integer.parseInt(t_str_qp1));
            }

            Cell row16_cell4 = row16.getCell(4);
            if (!"".equals(t_str_qp2)) {
                row16_cell4.setCellValue(Integer.parseInt(t_str_qp2));
            }

            Cell row16_cell5 = row16.getCell(5);
            if (!"".equals(t_str_qp3)) {
                row16_cell5.setCellValue(Integer.parseInt(t_str_qp3));
            }

            Cell row16_cell6 = row16.getCell(6);
            if (!"".equals(t_str_qp4)) {
                row16_cell6.setCellValue(Integer.parseInt(t_str_qp4));
            }

            Cell row16_cell7 = row16.getCell(7);
            if (!"".equals(t_str_qp5)) {
                row16_cell7.setCellValue(Integer.parseInt(t_str_qp5));
            }

            Cell row16_cell8 = row16.getCell(8);
            if (!"".equals(t_str_qp6)) {
                row16_cell8.setCellValue(Integer.parseInt(t_str_qp6));
            }

            Cell row16_cell9 = row16.getCell(9);
            if (!"".equals(t_str_qp7)) {
                row16_cell9.setCellValue(Integer.parseInt(t_str_qp7));
            }

            Cell row16_cell10 = row16.getCell(10);
            if (!"".equals(t_str_qp8)) {
                row16_cell10.setCellValue(Integer.parseInt(t_str_qp8));
            }

            Cell row16_cell11 = row16.getCell(11);
            if (!"".equals(t_totle7)) {
                row16_cell11.setCellValue(Integer.parseInt(t_totle7));
            }


            //箱子行
            Row row17 = sheet0.getRow(17);
            Cell row17_cell3 = row17.getCell(3);
            if (!"".equals(t_str_xz1)) {
                row17_cell3.setCellValue(Integer.parseInt(t_str_xz1));
            }

            Cell row17_cell4 = row17.getCell(4);
            if (!"".equals(t_str_xz2)) {
                row17_cell4.setCellValue(Integer.parseInt(t_str_xz2));
            }

            Cell row17_cell5 = row17.getCell(5);
            if (!"".equals(t_str_xz3)) {
                row17_cell5.setCellValue(Integer.parseInt(t_str_xz3));
            }

            Cell row17_cell6 = row17.getCell(6);
            if (!"".equals(t_str_xz4)) {
                row17_cell6.setCellValue(Integer.parseInt(t_str_xz4));
            }

            Cell row17_cell7 = row17.getCell(7);
            if (!"".equals(t_str_xz5)) {
                row17_cell7.setCellValue(Integer.parseInt(t_str_xz5));
            }

            Cell row17_cell8 = row17.getCell(8);
            if (!"".equals(t_str_xz6)) {
                row17_cell8.setCellValue(Integer.parseInt(t_str_xz6));
            }

            Cell row17_cell9 = row17.getCell(9);
            if (!"".equals(t_str_xz7)) {
                row17_cell9.setCellValue(Integer.parseInt(t_str_xz7));
            }

            Cell row17_cell10 = row17.getCell(10);
            if (!"".equals(t_str_xz8)) {
                row17_cell10.setCellValue(Integer.parseInt(t_str_xz8));
            }

            Cell row17_cell11 = row17.getCell(11);
            if (!"".equals(t_totle8)) {
                row17_cell11.setCellValue(Integer.parseInt(t_totle8));
            }


            if (jydwFzrId != 0) {
                User user = userMapper.getUserHyyJcById(jydwFzrId);
                //如果有印章
                if (!"".equals(user.getSealUrl())) {
                    //箱子行
                    Row row18 = sheet0.getRow(18);
                    //
                    //画图的顶级管理器，一个sheet只能获取一个（一定要注意这点）
                    Drawing patriarch = sheet0.createDrawingPatriarch();
                    //sheet0.setColumnWidth(2, 20 * 256);
                    row18.setHeight((short) (4 * 256));


                    // 签字时间
                    if (null != receiptTbBean.getQzrq() && !"".equals(receiptTbBean.getQzrq())) {
                        String shij = receiptTbBean.getQzrq();
                        String[] shiarr = shij.split("\\.");
                        //箱子行
                        Cell row18_cell10s = row18.getCell(10);
                        row18_cell10s.setCellValue(shiarr[0] + " 年 " + shiarr[1] + " 月 " + shiarr[2] + " 日");
                    }

                    //anchor主要用于设置图片的属性
                    //  dx1  第1个单元格中x轴的偏移量
                    //  dy1  第1个单元格中y轴的偏移量
                    //  dx2  第2个单元格中x轴的偏移量
                    //  dy2  第2个单元格中y轴的偏移量
                    //  col1 第1个单元格的列号
                    //  row1 第1个单元格的行号
                    //  col2 第2个单元格的列号
                    //  row2 第2个单元格的行号
                    ClientAnchor anchor = new XSSFClientAnchor(0, 0, 1024000, 1024000, 8, 18, 9, 18);
                    //插入图片
                    BASE64Decoder decoder = new BASE64Decoder();
                    byte[] decoderBytes = new byte[0];
                    try {
                        String mysel = user.getSealUrl();
                        String mysel2 = "";
                        if (mysel.length() > 50) {
                            mysel2 = mysel.substring(22, mysel.length());
                        }
                        decoderBytes = decoder.decodeBuffer(mysel2);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    patriarch.createPicture(anchor, workbook.addPicture(decoderBytes, HSSFWorkbook.PICTURE_TYPE_PNG));
                }
            }
//            //查询胡主任签名
//            List<User>  alldata = userMapper.getUserListJc();
//            for(User user:alldata){
//                //base64图片加水印
//                String jsStr = user.getRole();
//                String [] jsArray =jsStr.split(",");
//                List<String> listB= Arrays.asList(jsArray);
//                if(user.getUserId() == 18){
//
//                }
//            }


            String fileName = receiptTbBean.getRwdbh() + ".xlsx";
            downLoadExcel(fileName, response, workbook);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


    /**
     * 下载工作量确认单  本地的
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/api/dlGzlqrdQz2")
    public void excel2007Export2(HttpServletResponse response, HttpServletRequest request, String mbh, long jydwFzrId) {
        ResultMsg resultMsg = new ResultMsg();
        try {
            ClassPathResource cpr = new ClassPathResource("excleTemplate/qzb_gzlqrd3.xlsx");
            InputStream is = cpr.getInputStream();
            Workbook workbook = new XSSFWorkbook(is);
            Sheet sheet0 = workbook.getSheetAt(0);


            LocaGzlqrd locaGzlqrd = locaGzlqrdDao.getLocaGzlqrdById(mbh);
            if (null == locaGzlqrd) {

            } else {
                //设置 任务单编号
                Row row1 = sheet0.getRow(1);
                Cell row1_cell3 = row1.getCell(3);
                row1_cell3.setCellValue(locaGzlqrd.rwdbh);

                //设置委托方
                Row row2 = sheet0.getRow(2);
                Cell row2_cell13 = row2.getCell(3);
                row2_cell13.setCellValue(locaGzlqrd.wtfAll);

                Row row3 = sheet0.getRow(3);
                Cell row3_cell0 = row3.getCell(3);
                row3_cell0.setCellValue(locaGzlqrd.ypbh);

                Cell row9_cell0 = row3.getCell(9);
                row9_cell0.setCellValue(locaGzlqrd.jsrq);


                //面罩检验

                //设置面罩检验、气瓶检验、充气、维修
                Row row6 = sheet0.getRow(6);
                //面罩检验
                Cell row6_cell0 = row6.getCell(0);
                if (0 != locaGzlqrd.jymzNumber) {
                    row6_cell0.setCellValue(locaGzlqrd.jymzNumber);
                }

                //气瓶检验
                Cell row6_cell3 = row6.getCell(3);
                if (0 != locaGzlqrd.jyqpNumber) {
                    row6_cell3.setCellValue(locaGzlqrd.jyqpNumber);
                }
                //充气
                Cell row6_cell6 = row6.getCell(6);
                if (0 != locaGzlqrd.cqNumber) {
                    row6_cell6.setCellValue(locaGzlqrd.cqNumber);
                }

                //维修
                Cell row6_cell9 = row6.getCell(9);
                if (0 != locaGzlqrd.wxNumber) {
                    row6_cell9.setCellValue(locaGzlqrd.wxNumber);
                }


                //备注
                Row row7 = sheet0.getRow(7);
                Cell row7_cell0 = row7.getCell(0);
                if(null !=locaGzlqrd.gzlqrd_bz){
                    row7_cell0.setCellValue("备注："+locaGzlqrd.gzlqrd_bz);
                }



                //品牌名称
                Row row9 = sheet0.getRow(10);
                Cell row9_cell3 = row9.getCell(3);
                String t_mc1 = locaGzlqrd.mc1;
                if (!"".equals(t_mc1)) {
                    row9_cell3.setCellValue(t_mc1);
                }


                Cell row9_cell4 = row9.getCell(4);
                String t_mc2 = locaGzlqrd.mc2;
                if (!"".equals(t_mc2)) {
                    row9_cell4.setCellValue(t_mc2);
                }


                Cell row9_cell5 = row9.getCell(5);
                String t_mc3 = locaGzlqrd.mc3;
                if (!"".equals(t_mc3)) {
                    row9_cell5.setCellValue(t_mc3);
                }


                Cell row9_cell6 = row9.getCell(6);
                String t_mc4 = locaGzlqrd.mc4;
                if (!"".equals(t_mc4)) {
                    row9_cell6.setCellValue(t_mc4);
                }


                Cell row9_cell7 = row9.getCell(7);
                String t_mc5 = locaGzlqrd.mc5;
                if (!"".equals(t_mc5)) {
                    row9_cell7.setCellValue(t_mc5);
                }


                Cell row9_cell8 = row9.getCell(8);
                String t_mc6 = locaGzlqrd.mc6;
                if (!"".equals(t_mc6)) {
                    row9_cell8.setCellValue(t_mc6);
                }


                Cell row9_cell9 = row9.getCell(9);
                String t_mc7 = locaGzlqrd.mc7;
                if (!"".equals(t_mc7)) {
                    row9_cell9.setCellValue(t_mc7);
                }


                Cell row9_cell10 = row9.getCell(10);
                String t_mc8 = locaGzlqrd.mc8;
                if (!"".equals(t_mc8)) {
                    row9_cell10.setCellValue(t_mc8);
                }


                //面罩行
                Row row10 = sheet0.getRow(11);
                Cell row10_cell3 = row10.getCell(3);
                if (locaGzlqrd.mz1 != 0) {
                    row10_cell3.setCellValue(locaGzlqrd.mz1);
                }

                Cell row10_cell4 = row10.getCell(4);
                if (locaGzlqrd.mz2 != 0) {
                    row10_cell4.setCellValue(locaGzlqrd.mz2);
                }

                Cell row10_cell5 = row10.getCell(5);
                if (locaGzlqrd.mz3 != 0) {
                    row10_cell5.setCellValue(locaGzlqrd.mz3);
                }

                Cell row10_cell6 = row10.getCell(6);
                if (locaGzlqrd.mz4 != 0) {
                    row10_cell6.setCellValue(locaGzlqrd.mz4);
                }

                Cell row10_cell7 = row10.getCell(7);
                if (locaGzlqrd.mz5 != 0) {
                    row10_cell7.setCellValue(locaGzlqrd.mz5);
                }

                Cell row10_cell8 = row10.getCell(8);
                if (locaGzlqrd.mz6 != 0) {
                    row10_cell8.setCellValue(locaGzlqrd.mz6);
                }

                Cell row10_cell9 = row10.getCell(9);
                if (locaGzlqrd.mz7 != 0) {
                    row10_cell9.setCellValue(locaGzlqrd.mz7);
                }

                Cell row10_cell10 = row10.getCell(10);
                if (locaGzlqrd.mz8 != 0) {
                    row10_cell10.setCellValue(locaGzlqrd.mz8);
                }

                Cell row10_cell11 = row10.getCell(11);
                if (locaGzlqrd.t_mz != 0) {
                    row10_cell11.setCellValue(locaGzlqrd.t_mz);
                }


                //供气阀行
                Row row11 = sheet0.getRow(12);
                Cell row11_cell3 = row11.getCell(3);
                if (locaGzlqrd.gqf1 != 0) {
                    row11_cell3.setCellValue(locaGzlqrd.gqf1);
                }

                Cell row11_cell4 = row11.getCell(4);
                if (locaGzlqrd.gqf2 != 0) {
                    row11_cell4.setCellValue(locaGzlqrd.gqf2);
                }

                Cell row11_cell5 = row11.getCell(5);
                if (locaGzlqrd.gqf3 != 0) {
                    row11_cell5.setCellValue(locaGzlqrd.gqf3);
                }

                Cell row11_cell6 = row11.getCell(6);
                if (locaGzlqrd.gqf4 != 0) {
                    row11_cell6.setCellValue(locaGzlqrd.gqf4);
                }

                Cell row11_cell7 = row11.getCell(7);
                if (locaGzlqrd.gqf5 != 0) {
                    row11_cell7.setCellValue(locaGzlqrd.gqf5);
                }

                Cell row11_cell8 = row11.getCell(8);
                if (locaGzlqrd.gqf6 != 0) {
                    row11_cell8.setCellValue(locaGzlqrd.gqf6);
                }

                Cell row11_cell9 = row11.getCell(9);
                if (locaGzlqrd.gqf7 != 0) {
                    row11_cell9.setCellValue(locaGzlqrd.gqf7);
                }

                Cell row11_cell10 = row11.getCell(10);
                if (locaGzlqrd.gqf8 != 0) {
                    row11_cell10.setCellValue(locaGzlqrd.gqf8);
                }

                Cell row11_cell11 = row11.getCell(11);
                if (locaGzlqrd.t_gqf != 0) {
                    row11_cell11.setCellValue(locaGzlqrd.t_gqf);
                }


                //报警器 行
                Row row12 = sheet0.getRow(13);
                Cell row12_cell3 = row12.getCell(3);
                if (locaGzlqrd.bjq1 != 0) {
                    row12_cell3.setCellValue(locaGzlqrd.bjq1);
                }

                Cell row12_cell4 = row12.getCell(4);
                if (locaGzlqrd.bjq2 != 0) {
                    row12_cell4.setCellValue(locaGzlqrd.bjq2);
                }

                Cell row12_cell5 = row12.getCell(5);
                if (locaGzlqrd.bjq3 != 0) {
                    row12_cell5.setCellValue(locaGzlqrd.bjq3);
                }

                Cell row12_cell6 = row12.getCell(6);
                if (locaGzlqrd.bjq4 != 0) {
                    row12_cell6.setCellValue(locaGzlqrd.bjq4);
                }

                Cell row12_cell7 = row12.getCell(7);
                if (locaGzlqrd.bjq5 != 0) {
                    row12_cell7.setCellValue(locaGzlqrd.bjq5);
                }

                Cell row12_cell8 = row12.getCell(8);
                if (locaGzlqrd.bjq6 != 0) {
                    row12_cell8.setCellValue(locaGzlqrd.bjq6);
                }

                Cell row12_cell9 = row12.getCell(9);
                if (locaGzlqrd.bjq7 != 0) {
                    row12_cell9.setCellValue(locaGzlqrd.bjq7);
                }

                Cell row12_cell10 = row12.getCell(10);
                if (locaGzlqrd.bjq8 != 0) {
                    row12_cell10.setCellValue(locaGzlqrd.bjq8);
                }

                Cell row12_cell11 = row12.getCell(11);
                if (locaGzlqrd.t_bjq != 0) {
                    row12_cell11.setCellValue(locaGzlqrd.t_bjq);
                }


                //压力表
                Row row13 = sheet0.getRow(14);
                Cell row13_cell3 = row13.getCell(3);
                if (locaGzlqrd.ylb1 != 0) {
                    row13_cell3.setCellValue(locaGzlqrd.ylb1);
                }

                Cell row13_cell4 = row13.getCell(4);
                if (locaGzlqrd.ylb2 != 0) {
                    row13_cell4.setCellValue(locaGzlqrd.ylb2);
                }

                Cell row13_cell5 = row13.getCell(5);
                if (locaGzlqrd.ylb3 != 0) {
                    row13_cell5.setCellValue(locaGzlqrd.ylb3);
                }

                Cell row13_cell6 = row13.getCell(6);
                if (locaGzlqrd.ylb4 != 0) {
                    row13_cell6.setCellValue(locaGzlqrd.ylb4);
                }

                Cell row13_cell7 = row13.getCell(7);
                if (locaGzlqrd.ylb5 != 0) {
                    row13_cell7.setCellValue(locaGzlqrd.ylb5);
                }

                Cell row13_cell8 = row13.getCell(8);
                if (locaGzlqrd.ylb6 != 0) {
                    row13_cell8.setCellValue(locaGzlqrd.ylb6);
                }

                Cell row13_cell9 = row13.getCell(9);
                if (locaGzlqrd.ylb7 != 0) {
                    row13_cell9.setCellValue(locaGzlqrd.ylb7);
                }

                Cell row13_cell10 = row13.getCell(10);
                if (locaGzlqrd.ylb8 != 0) {
                    row13_cell10.setCellValue(locaGzlqrd.ylb8);
                }

                Cell row13_cell11 = row13.getCell(11);
                if (locaGzlqrd.t_ylb != 0) {
                    row13_cell11.setCellValue(locaGzlqrd.t_ylb);
                }


                //背具总成 行
                Row row14 = sheet0.getRow(15);
                Cell row14_cell3 = row14.getCell(3);
                if (locaGzlqrd.zc1 != 0) {
                    row14_cell3.setCellValue(locaGzlqrd.zc1);
                }

                Cell row14_cell4 = row14.getCell(4);
                if (locaGzlqrd.zc2 != 0) {
                    row14_cell4.setCellValue(locaGzlqrd.zc2);
                }

                Cell row14_cell5 = row14.getCell(5);
                if (locaGzlqrd.zc3 != 0) {
                    row14_cell5.setCellValue(locaGzlqrd.zc3);
                }

                Cell row14_cell6 = row14.getCell(6);
                if (locaGzlqrd.zc4 != 0) {
                    row14_cell6.setCellValue(locaGzlqrd.zc4);
                }

                Cell row14_cell7 = row14.getCell(7);
                if (locaGzlqrd.zc5 != 0) {
                    row14_cell7.setCellValue(locaGzlqrd.zc5);
                }

                Cell row14_cell8 = row14.getCell(8);
                if (locaGzlqrd.zc6 != 0) {
                    row14_cell8.setCellValue(locaGzlqrd.zc6);
                }

                Cell row14_cell9 = row14.getCell(9);
                if (locaGzlqrd.zc7 != 0) {
                    row14_cell9.setCellValue(locaGzlqrd.zc7);
                }

                Cell row14_cell10 = row14.getCell(10);
                if (locaGzlqrd.zc8 != 0) {
                    row14_cell10.setCellValue(locaGzlqrd.zc8);
                }

                Cell row14_cell11 = row14.getCell(11);
                if (locaGzlqrd.t_zc != 0) {
                    row14_cell11.setCellValue(locaGzlqrd.t_zc);
                }


                //瓶阀行
                Row row15 = sheet0.getRow(16);
                Cell row15_cell3 = row15.getCell(3);
                if (locaGzlqrd.pf1 != 0) {
                    row15_cell3.setCellValue(locaGzlqrd.pf1);
                }

                Cell row15_cell4 = row15.getCell(4);
                if (locaGzlqrd.pf2 != 0) {
                    row15_cell4.setCellValue(locaGzlqrd.pf2);
                }

                Cell row15_cell5 = row15.getCell(5);
                if (locaGzlqrd.pf3 != 0) {
                    row15_cell5.setCellValue(locaGzlqrd.pf3);
                }

                Cell row15_cell6 = row15.getCell(6);
                if (locaGzlqrd.pf4 != 0) {
                    row15_cell6.setCellValue(locaGzlqrd.pf4);
                }

                Cell row15_cell7 = row15.getCell(7);
                if (locaGzlqrd.pf5 != 0) {
                    row15_cell7.setCellValue(locaGzlqrd.pf5);
                }

                Cell row15_cell8 = row15.getCell(8);
                if (locaGzlqrd.pf6 != 0) {
                    row15_cell8.setCellValue(locaGzlqrd.pf6);
                }

                Cell row15_cell9 = row15.getCell(9);
                if (locaGzlqrd.pf7 != 0) {
                    row15_cell9.setCellValue(locaGzlqrd.pf7);
                }

                Cell row15_cell10 = row15.getCell(10);
                if (locaGzlqrd.pf8 != 0) {
                    row15_cell10.setCellValue(locaGzlqrd.pf8);
                }

                Cell row15_cell11 = row15.getCell(11);
                if (locaGzlqrd.t_qf != 0) {
                    row15_cell11.setCellValue(locaGzlqrd.t_qf);
                }


                //气瓶行
                Row row16 = sheet0.getRow(17);
                Cell row16_cell3 = row16.getCell(3);
                if (locaGzlqrd.qp1 != 0) {
                    row16_cell3.setCellValue(locaGzlqrd.qp1);
                }

                Cell row16_cell4 = row16.getCell(4);
                if (locaGzlqrd.qp2 != 0) {
                    row16_cell4.setCellValue(locaGzlqrd.qp2);
                }

                Cell row16_cell5 = row16.getCell(5);
                if (locaGzlqrd.qp3 != 0) {
                    row16_cell5.setCellValue(locaGzlqrd.qp3);
                }

                Cell row16_cell6 = row16.getCell(6);
                if (locaGzlqrd.qp4 != 0) {
                    row16_cell6.setCellValue(locaGzlqrd.qp4);
                }

                Cell row16_cell7 = row16.getCell(7);
                if (locaGzlqrd.qp5 != 0) {
                    row16_cell7.setCellValue(locaGzlqrd.qp5);
                }

                Cell row16_cell8 = row16.getCell(8);
                if (locaGzlqrd.qp6 != 0) {
                    row16_cell8.setCellValue(locaGzlqrd.qp6);
                }

                Cell row16_cell9 = row16.getCell(9);
                if (locaGzlqrd.qp7 != 0) {
                    row16_cell9.setCellValue(locaGzlqrd.qp7);
                }

                Cell row16_cell10 = row16.getCell(10);
                if (locaGzlqrd.qp8 != 0) {
                    row16_cell10.setCellValue(locaGzlqrd.qp8);
                }

                Cell row16_cell11 = row16.getCell(11);
                if (locaGzlqrd.t_qp != 0) {
                    row16_cell11.setCellValue(locaGzlqrd.t_qp);
                }


                //箱子行
                Row row17 = sheet0.getRow(18);
                Cell row17_cell3 = row17.getCell(3);
                if (locaGzlqrd.xz1 != 0) {
                    row17_cell3.setCellValue(locaGzlqrd.xz1);
                }

                Cell row17_cell4 = row17.getCell(4);
                if (locaGzlqrd.xz2 != 0) {
                    row17_cell4.setCellValue(locaGzlqrd.xz2);
                }

                Cell row17_cell5 = row17.getCell(5);
                if (locaGzlqrd.xz3 != 0) {
                    row17_cell5.setCellValue(locaGzlqrd.xz3);
                }

                Cell row17_cell6 = row17.getCell(6);
                if (locaGzlqrd.xz4 != 0) {
                    row17_cell6.setCellValue(locaGzlqrd.xz4);
                }

                Cell row17_cell7 = row17.getCell(7);
                if (locaGzlqrd.xz5 != 0) {
                    row17_cell7.setCellValue(locaGzlqrd.xz5);
                }

                Cell row17_cell8 = row17.getCell(8);
                if (locaGzlqrd.xz6 != 0) {
                    row17_cell8.setCellValue(locaGzlqrd.xz6);
                }

                Cell row17_cell9 = row17.getCell(9);
                if (locaGzlqrd.xz7 != 0) {
                    row17_cell9.setCellValue(locaGzlqrd.xz7);
                }

                Cell row17_cell10 = row17.getCell(10);
                if (locaGzlqrd.xz8 != 0) {
                    row17_cell10.setCellValue(locaGzlqrd.xz8);
                }

                Cell row17_cell11 = row17.getCell(11);
                if (locaGzlqrd.t_xz != 0) {
                    row17_cell11.setCellValue(locaGzlqrd.t_xz);
                }


                if (jydwFzrId != 0) {
                    User user = userMapper.getUserHyyJcById(jydwFzrId);
                    //如果有印章
                    if (!"".equals(user.getSealUrl())) {
                        //箱子行
                        Row row18 = sheet0.getRow(19);
                        //
                        //画图的顶级管理器，一个sheet只能获取一个（一定要注意这点）
                        Drawing patriarch = sheet0.createDrawingPatriarch();
                        //sheet0.setColumnWidth(2, 20 * 256);
                        row18.setHeight((short) (4 * 256));


                        // 签字时间
                        if (null != locaGzlqrd.qzrq && !"".equals(locaGzlqrd.qzrq)) {
                            String shij = locaGzlqrd.qzrq;
                            String[] shiarr = shij.split("\\.");
                            //箱子行
                            Cell row18_cell10s = row18.getCell(10);
                            row18_cell10s.setCellValue(shiarr[0] + " 年 " + shiarr[1] + " 月 " + shiarr[2] + " 日");
                        }

                        //anchor主要用于设置图片的属性
                        //  dx1  第1个单元格中x轴的偏移量
                        //  dy1  第1个单元格中y轴的偏移量
                        //  dx2  第2个单元格中x轴的偏移量
                        //  dy2  第2个单元格中y轴的偏移量
                        //  col1 第1个单元格的列号
                        //  row1 第1个单元格的行号
                        //  col2 第2个单元格的列号
                        //  row2 第2个单元格的行号
                        ClientAnchor anchor = new XSSFClientAnchor(0, 0, 1024000, 1024000, 8, 19, 9, 19);
                        //插入图片
                        BASE64Decoder decoder = new BASE64Decoder();
                        byte[] decoderBytes = new byte[0];
                        try {
                            String mysel = user.getSealUrl();
                            String mysel2 = "";
                            if (mysel.length() > 50) {
                                mysel2 = mysel.substring(22, mysel.length());
                            }
                            decoderBytes = decoder.decodeBuffer(mysel2);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        patriarch.createPicture(anchor, workbook.addPicture(decoderBytes, HSSFWorkbook.PICTURE_TYPE_PNG));
                    }
                }

                String fileName = locaGzlqrd.rwdbh + ".xlsx";
                downLoadExcel(fileName, response, workbook);
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


}
